objective c - ios app crashes for some users when using ALAssetsLibrary to retrieve images in a UICollectionView -
i have ios app, have accessing images gallery using alassetlibrary populate uicollectionview. working fine test users in india(my home country) not working on devices of our client in usa. crashes when client opens collection view following error:
fatal exception: nsinvalidargumentexception *** -[__nsarraym insertobject:atindex:]: object cannot nil thread : fatal exception: nsinvalidargumentexception 0 corefoundation 0x182ef9900 __exceptionpreprocess 1 libobjc.a.dylib 0x182567f80 objc_exception_throw 2 corefoundation 0x182de3134 cfstringconvertnsstringencodingtoencoding 3 quikcom 0x10009e594 __27-[imageselector loadassets]_block_invoke_2 (imageselector.m:65) 4 assetslibrary 0x18c74ba4c __62-[alassetsgroup _enumerateassetsatindexes:options:usingblock:]_block_invoke147 5 corefoundation 0x182df0370 __53-[__nsarraym enumerateobjectswithoptions:usingblock:]_block_invoke 6 corefoundation 0x182df0268 -[__nsarraym enumerateobjectswithoptions:usingblock:] 7 assetslibrary 0x18c74b520 -[alassetsgroup _enumerateassetsatindexes:options:usingblock:] 8 quikcom 0x10009e4a4 __27-[imageselector loadassets]_block_invoke (imageselector.m:60) 9 assetslibrary 0x18c74d8e4 __68-[alassetslibrary enumerategroupswithtypes:usingblock:failureblock:]_block_invoke_3 10 corefoundation 0x182df0370 __53-[__nsarraym enumerateobjectswithoptions:usingblock:]_block_invoke 11 corefoundation 0x182df01e0 -[__nsarraym enumerateobjectswithoptions:usingblock:] 12 assetslibrary 0x18c74d83c __68-[alassetslibrary enumerategroupswithtypes:usingblock:failureblock:]_block_invoke_2 13 libdispatch.dylib 0x18294d630 _dispatch_call_block_and_release 14 libdispatch.dylib 0x18294d5f0 _dispatch_client_callout 15 libdispatch.dylib 0x182952cf8 _dispatch_main_queue_callback_4cf 16 corefoundation 0x182eb0bb0 __cfrunloop_is_servicing_the_main_dispatch_queue__ 17 corefoundation 0x182eaea18 __cfrunlooprun 18 corefoundation 0x182ddd680 cfrunlooprunspecific 19 graphicsservices 0x1842ec088 gseventrunmodal 20 uikit 0x187c54d90 uiapplicationmain 21 quikcom 0x1000a1258 main (main.m:14) 22 libdispatch.dylib 0x18297e8b8 (missing)
then put check nil values. code fetch images follows:
-(void)loadassets{ __block alassetslibrary *library = [[alassetslibrary alloc] init]; [library enumerategroupswithtypes:alassetsgroupall usingblock:^(alassetsgroup *group, bool *stop) { if (group == nil) { return; } [group setassetsfilter:[alassetsfilter allphotos]]; if ( group != nil && [group numberofassets] > 0) { [group enumerateassetswithoptions:nsenumerationreverse usingblock:^(alasset *alasset, nsuinteger index, bool *innerstop) { if (alasset) { alassetrepresentation *representation = [alasset defaultrepresentation]; uiimage *latestphotothumbnail = [uiimage imagewithcgimage:[alasset thumbnail]]; if (representation != nil &&representation.url != nil && latestphotothumbnail != null) { [urlarray addobject:representation.url]; [thumbsarr addobject:latestphotothumbnail]; representation = nil; latestphotothumbnail = nil; } }else{ library = nil; [_collectionview reloaddata]; } }]; } [_collectionview reloaddata]; } failureblock: ^(nserror *error) { //nslog(@"no groups: %@",error); }]; }
after app did not crash collection view rendering empty cells without image thumbnails. not have idea doing wrong.
Comments
Post a Comment