프로그래밍/iOS,macOS

싱글톤

chance 2016. 10. 19. 12:21

싱글톤


+(id) instance

{

static dispatch_once_t pred;

static MyClass *obj=nil;


dispatch_once(&pred, ^{

obj = [[MyClass alloc] init];

});


return obj;

}



class MyClass

{

static let instance = MyClass();

}

저작자표시 비영리 변경금지 (새창열림)