項(xiàng)目中需要在每個(gè)控制器中添加一個(gè)可以訪問的變量,最開始的思路是單例,但是覺得太麻煩了.
數(shù)據(jù)保護(hù)中數(shù)據(jù)不為空的情況:
+ (BOOL) isBlankString:(NSString *)string {
if (string == nil || string == NULL) {
return YES;
}
if ([string isKindOfClass:[NSNull class]]) {
return YES;
}
if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0) {
return YES;
}
return NO;
}