Question

hi i am new to iphone programing,i am using EGOPhotViewer and want to show images by using this code,

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];

and i get this error

*** 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
Was it helpful?

Solution

i solved this by writing this code

 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];




}

OTHER TIPS

[__NSArrayI objectAtIndex:]: index 2147483648 beyond bounds [0 .. 0]'

2147483648 is NSNotFound. Somewhere in your code, or the code of a library you are using, something like indexOfObject: is being used on one array, and that index is being used to get a value from another array, and it is failing.

Your for loop looks very suspect. You're assigning a value to photoController at the end of each iteration, meaning only the value you assign last will actually get used. I'm not familiar with the library you're using but you probably want to be building up an array of MyPhoto objects before passing them to a single photoController.

Make sure initWithImageURL: name: inside MyPhoto returns self. Verify this with NSLog(@"%@", [photo debugDescription]);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top