我有一段代码可以检测 aNSString
是否为NULL
,nil
等。但是,它崩溃了。这是我的代码:
NSArray *resultstwo = [database executeQuery:@"SELECT * FROM processes WHERE ready='yes' LIMIT 0,1"];
for (NSDictionary *rowtwo in resultstwo) {
NSString *getCaption = [rowtwo valueForKey:@"caption"];
if (getCaption == NULL) {
theCaption = @"Photo uploaded...";
} else if (getCaption == nil) {
theCaption = @"Photo uploaded...";
} else if ([getCaption isEqualToString:@""]) {
theCaption = @"Photo uploaded...";
} else if ([getCaption isEqualToString:@" "]) {
theCaption = @"Photo uploaded...";
}
}
这是错误:
由于未捕获的异常“
NSInvalidArgumentException
”而终止应用程序,原因:“-[NSNull isEqualToString:]
:无法识别的选择器发送到实例0x3eba63d4
”
难道我做错了什么?我需要以不同的方式来做吗?