gpt4 book ai didi

ios - 如何解决 NSRangeException

转载 作者:行者123 更新时间:2023-11-28 18:38:24 28 4
gpt4 key购买 nike

你好我是 iPhone 编程的新手,我正在使用 EGOPhotViewer 并想通过使用此代码显示图像,

for ( recipeImages in recipeImages.imgArray) {

photo = [[MyPhoto alloc] initWithImageURL:[NSURL URLWithString:recipeImages.recipie_img_url]name:recipeImages.recipe_name];
NSLog(@"%@",recipeImages.recipie_img_url);

MyPhotoSource *source = [[MyPhotoSource alloc] initWithPhotos:[NSArray arrayWithObjects:photo ,nil]];
photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];


}


[APPDELEGATE.navigationController pushViewController:photoController animated:YES];

我得到了这个错误

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 2147483648 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x225f012 0x2084e7e 0x2214b44 0x9e1e4 0xa46c4 0x1b45dc9 0x22b90c5 0x2213efa 0x1a7a482 0x1a8d73b 0xa9d7c 0xa6a4e 0xa5081 0xa0499 0x10af753 0x10afa7b 0x10bd590 0x10c55bd 0x10c5eab 0x10c64a3 0x10c6098 0x5bad6 0x2098705 0xfcf920 0xfcf8b8 0x1090671 0x1090bcf 0x108fd38 0xfff33f 0xfff552 0xfdd3aa 0xfcecf8 0x2c15df9 0x2c15ad0 0x21d4bf5 0x21d4962 0x2205bb6 0x2204f44 0x2204e1b 0x2c147e3 0x2c14668 0xfcc65c 0x263a 0x2545)
libc++abi.dylib: terminate called throwing an exception

最佳答案

我通过编写这段代码解决了这个问题

 NSMutableArray *localImagesArray = [[NSMutableArray alloc] init];

for ( recipeImages in recipeImages.imgArray) {
photo = [[MyPhoto alloc] initWithImageURL:[NSURL URLWithString:recipeImages.recipie_img_url]name:recipeImages.recipe_name];
NSLog(@"%@",recipeImages.recipie_img_url);
NSLog(@"%@", [photo debugDescription]);
[localImagesArray addObject:photo];
}


MyPhotoSource *source = [[MyPhotoSource alloc] initWithPhotos:localImagesArray];
photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];



[APPDELEGATE.navigationController pushViewController:photoController animated:YES];




}

关于ios - 如何解决 NSRangeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15038309/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com