我收到以下错误:[__NSArrayM addObject:]
,NIL对象。但不是崩溃,我想知道为什么要显示这个提醒。
这是我的代码
NSMutableArray *picturesCounts = [NSMutableArray array];
NSMutableArray *bigUrlArray = [NSMutableArray array];
NSMutableArray *pitcturesArray = [NSMutableArray array];
NSInteger i = 1;
for (TNHotelPictures *picture in pictures) {
NSString *pictureCounts = [NSString stringWithFormat:@"%ld",(long)picture.images.count];
[picturesCounts addObject:pictureCounts];
[pitcturesArray addObject:picture.images];
for (TNHotelDetailPhotoImages *photoImage in picture.images) {
[bigUrlArray addObject:photoImage.bigUrl];
}
i++;
}
NSInteger imageInAllIndex = imageIndex;
NSMutableArray *imagesCount = [NSMutableArray array];
for (NSInteger m = 0; m<i; m++) {
imagesCount = pitcturesArray[(typeIndex-(m+1))] ;
imageInAllIndex += imagesCount.count;
}
NSMutableArray *array = [NSMutableArray array];
for (NSString *url in bigUrlArray)
{
if (![url isKindOfClass:[NSString class]])
{
return;
}
TNHotelPhoto *photo = [[TNHotelPhoto alloc] initWithImageURL:[NSURL URLWithString:url]];
[array addObject:photo];
}
TNHotelPhotoSource *source = [[TNHotelPhotoSource alloc] initWithPhotos:array];
TNHotelDetailPhotoBrowserViewController *browserVC = [[TNHotelDetailPhotoBrowserViewController alloc] initWithPhotoSource:source WithImageIndex:imageInAllIndex>=0?imageInAllIndex:0 andImageArray:pictures andTypeIndex:typeIndex];
[UIManager showViewController:browserVC];
}
答案 0 :(得分:0)
这意味着该对象已初始化并在内存中保存引用。它不是NIL
。
答案 1 :(得分:0)
查看您的代码:
for (TNHotelPictures *picture in pictures) {
NSString *pictureCounts = [NSString stringWithFormat:@"%ld",(long)picture.images.count];
[picturesCounts addObject:pictureCounts];
[pitcturesArray addObject:picture.images];
for (TNHotelDetailPhotoImages *photoImage in picture.images) {
[bigUrlArray addObject:photoImage.bigUrl];
}
i++;
}
我认为您应该检查picture
其属性pictureCounts
,images
,bigUrl
是否为零。