有时 JSON 从获取数据的数据库返回 (null)
,因此我会检查它是否已返回该 (null)
。
else if (NSOrderedSame == [[clubsArray objectAtIndex:indexPath.row] compare:@"(null)"] )
但是 Xcode 警告我
Incompatible Objective-C types 'struct NSString *', expected 'struct NSNumber *' when passing argument 1 of 'compare:' from distinct Objective-C type
我将 NSString
添加到该数组中,因此我很困惑为什么它谈论结构。
NSString *clubNameReturned = [message objectForKey:@"clubname"];
[clubsArray addObject:clubNameReturned];
有人能解释一下这里发生的事情吗?
代码按照我的预期执行,但我不想做一些不正确的事情。
最佳答案
JSON 不返回“(null)”字符串。此字符串“(null)”仅是当您 NSLog 空单例对象时控制台上显示的内容(它是 description
表示形式)。
与 [NSNull null]
进行比较,即 a singleton especially used to store something that represent the null/nil value on containers .
关于objective-c - 比较 NSString 和有关 NSNumber 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6416335/