通用单例的写法

+ (id)sharedInstance{
    static id sharedInstance;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        sharedInstance = [[[self class] alloc] init];
    });
    return sharedInstance;
}

posted on 2014-03-14 14:37  流れ星ーー  阅读(110)  评论(0编辑  收藏  举报

导航