【发布时间】:2012-01-05 06:11:04
【问题描述】:
代码:
NSString *tempPhone = [NSString stringWithFormat:@"%@", [personDict objectForKey:kPhoneKey]];
NSLog(@"NSString *tempPhone = %@",tempPhone);
输出:
NSString *tempPhone = <null>
现在我想添加 if 条件,对于 not null;我尝试了以下方法:
if (tempEmail != NULL)
if (tempPhone != Nil)
if (tempPhone != nil)
if (![tempPhone compare:@"<null>"])
if (tempPhone != (NSString*)[NSNull null])
我也查了this Post.
它们都不适合我。我哪里错了??
【问题讨论】:
-
你实现
if([tempPhone length]==0)条件了吗?我认为这会对你有所帮助。 -
表示您正在获取具有空值的字符串长度?
-
是的,它是“6”。我认为这是一个包含 "
" 的字符串
标签: iphone objective-c ios if-statement