字符串操作

objective-c 中判断字符串 是否为空:

NSManagedObject* object=[self.listDataobjectAtIndex:i];
NSString* orderby = [object valueForKey:@"orderby"]; 
NSLog(@"orderby::%d",orderby.length==0); //可以
NSLog(@"orderby::%d",[orderby isEqualToString:@""]); //不可以
NSLog(@"orderby::%d",[orderby isEqual:Nil]); //不可以
NSLog(@"orderby::%d",!orderby); //可以



参考:

http://www.cnblogs.com/zander/archive/2012/09/03/2668557.html


你可能感兴趣的:(字符串操作)