我得到一个空值的数组。请检查下面我的数组的结构:
(
"< null>"
)
当我尝试访问索引 0 时,它崩溃了,因为
-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x389cea70
目前它因为带有崩溃日志的数组而崩溃:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x389cea70'
*** First throw call stack:
(0x2d9fdf53 0x3820a6af 0x2da018e7 0x2da001d3 0x2d94f598 0x1dee57 0x1dfd31 0x302f598d 0x301a03e3 0x3052aeed 0x3016728b 0x301659d3 0x3019ec41 0x3019e5e7 0x30173a25 0x30172221 0x2d9c918b 0x2d9c865b 0x2d9c6e4f 0x2d931ce7 0x2d931acb 0x3262c283 0x301d3a41 0xabb71 0xabaf8)
libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
id object = myArray[0];// similar to [myArray objectAtIndex:0]
if(![object isEqual:[NSNull null]])
{
//do something if object is not equals to [NSNull null]
}
https://stackoverflow.com/questions/19059202/
相关文章:
iphone - NSNumber 和 NSInteger 有什么区别?
objective-c - 将参数传递给由 NSTimer 调用的方法
ios - MKMapView:自定义 View 代替 Annotation Pin
iphone - 快速将单个引脚添加到 MKMapView?
objective-c - 将 Xcode 组创建为文件系统文件夹的工作流程
ios - 如何使用图像和标签制作自定义 UIBarButtonItem?
objective-c - 具有多个目标的 Objective C 到 Swift 头文件
ios - 按字典中键的值对字典的 NSArray 进行排序