iOS 线程安全的单例

+ (instancetype)sharedStore {
    static OBJ *sharedObj = nil;
    
    // Not thread safe
    /*if (!sharedStore) {
        sharedStore = [[self alloc]initPrivate];
    }*/
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedObj = [[self alloc] initPrivate];
    });
    
    return  sharedStore;
}


- (instancetype)initPrivate {
    self = [super init];
    if (self) {
        //do some initialize
    }
    return self;
}

- (instancetype) init {
    @throw [NSException exceptionWithName:@"Singleton" reason:@"PLS use +[OBJ sharedObj]" userInfo:nil];
    return nil;
}

iPad Modal View 样式

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:aRootViewController];
navController.modalPresentationStyle = UIModalPresentationFormSheet;

//navController.modalPresentationStyle = UIModalPresentationPageSheet;

[self presentViewController:navController animation:YES completion:nil];

iOS Frame vs Bounds

Alt none

一篇很不错的的文章,建议大家移步阅读: iOS开发之窗口和视图

NSLayoutConstraint 表达式

Alt none

ref: iOS Programming (4th Edition)

Android 常用编译命令

Alt none