獲取app版本號 [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; //app版本號 [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; //build 獲取系統版本號 [UIDevice currentDevice].systemVersion; 判斷字符串是否為空 我習慣把它定義成宏,數組字典類似。 if (str == nil || (NSNull *)str == [NSNull null] || str.length == 0) {} 打印沙盒路徑 NSLog(@"app = %@",NSHomeDirectory()); 不想讓tableView顯示無用的cell分割線 self.tableView.tableFooterView = [[UIView alloc] init]; 用NSLog輸出NSRange,CGRect等結構體 NSString中的方法: NSStringFromCGPoint(CGPoint point); NSStringFromCGVector(CGVector vector); NSStringFromCGSize(CGSize size); NSStringFromCGRect(CGRect rect); NSStringFromCGAffineTransform(CGAffineTransform transform); NSStringFromUIEdgeInsets(UIEdgeInsets insets); NSStringFromUIOffset(UIOffset offset); NSLog(@"%@",NSStringFromCGPoint(CGPointZero)); 隱藏navigationBar 有時候我們使用navigationController,需要首頁隱藏導航欄其他頁面顯示導航欄。 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; }