헤더파일에서
@interface SingleToneSample : NSObject
+ (instancetype) sharedInstance;
@end
처럼 간단하게 공개용 함수만들고 구현파일에서는
+(instancetype)sharedInstance {
static SingleToneSample *shared = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shared = [[SingleToneSample alloc] init];
});
return shared;
}처럼 실체를 만들면된다.
참고
https://padgom.tistory.com/entry/iOS-%EA%B8%B0%EB%B3%B8-GCDGrand-Central-Dispatch-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0
0 comments:
댓글 쓰기