IOS获取系统相册图片名称在非ARC模式下报错

dispatch_async(dispatch_get_main_queue(), ^{

    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset){

        ALAssetRepresentation *representation = [myasset defaultRepresentation];

        NSString *fileName = [representation filename];

        NSLog(@"fileName : %@",[representation filename]);
    };

    NSURL *imageURL = [info valueForKey:UIImagePickerControllerReferenceURL];

    ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
    [assetslibrary assetForURL:imageURL
                   resultBlock:resultblock
                  failureBlock:nil];

});

    报错信息:
    -[__NSArrayI scheme]: unrecognized selector sent to instance 0x7ff84d58a1f0

2015-12-11 09:49:45.126 MobileOA[1126:25670] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI scheme]: unrecognized selector sent to instance 0x7ff84d58a1f0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001092cff65 exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000108c94deb objc_exception_throw + 48
2 CoreFoundation 0x00000001092d858d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000109225f7a ___forwarding
_ + 970
4 CoreFoundation 0x0000000109225b28 CF_forwarding_prep_0 + 120
5 PhotoLibraryServices 0x000000010cb2b65b +[PLManagedAsset photoFromAssetURL:photoLibrary:sidecar:] + 83
6 AssetsLibrary 0x0000000106cf89bf __56-[ALAssetsLibrary assetForURL:resultBlock:failureBlock:]_block_invoke324 + 36
7 CoreData 0x0000000111af0f17 developerSubmittedBlockToNSManagedObjectContextPerform + 199
8 libdispatch.dylib 0x0000000109a6049b _dispatch_client_callout + 8
9 libdispatch.dylib 0x0000000109a45051 _dispatch_barrier_sync_f_invoke + 393
10 CoreData 0x0000000111af0dfc -[NSManagedObjectContext performBlockAndWait:] + 252
11 AssetsLibrary 0x0000000106cf5dcc -[ALAssetsLibrary _performBlockAndWait:] + 134
12 AssetsLibrary 0x0000000106cf888c __56-[ALAssetsLibrary assetForURL:resultBlock:failureBlock:]_block_invoke_2 + 191
13 libdispatch.dylib 0x0000000109a3fef9 _dispatch_call_block_and_release + 12
14 libdispatch.dylib 0x0000000109a6049b _dispatch_client_callout + 8
15 libdispatch.dylib 0x0000000109a4834b _dispatch_main_queue_callback_4CF + 1738
16 CoreFoundation 0x00000001092303e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
_ + 9
17 CoreFoundation 0x00000001091f1939 __CFRunLoopRun + 2073
18 CoreFoundation 0x00000001091f0e98 CFRunLoopRunSpecific + 488
19 GraphicsServices 0x000000010a7adad2 GSEventRunModal + 161
20 UIKit 0x000000010718a676 UIApplicationMain + 171
21 MobileOA 0x0000000105b6ee81 main + 97
22 libdyld.dylib 0x0000000109a9492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

求大神帮忙看看,求解决啊

2个回答

'dispatch_get_main_queue': identifier not found (犯错率:0% 犯错数:0 人)
在语言符号 ) 前漏写语言符号 { (犯错率:11.3% 犯错数:91 人)
建议:可能缺少“{”、“)”或“;”等语言符号
‘)’语法错误 (犯错率:8.6% 犯错数:69 人)
建议:引起错误的原因很多,可能多加或少加了符号.*
在语言符号 ; 前漏写语言符号 { (犯错率:11.3% 犯错数:91 人)
建议:可能缺少“{”、“)”或“;”等语言符号
'{' : missing function header (old-style formal list?) (犯错率:0% 犯错数:0 人)
unknown character '0x40' (犯错率:0% 犯错数:0 人)
‘)’语法错误 (犯错率:8.6% 犯错数:69 人)
建议:引起错误的原因很多,可能多加或少加了符号.*

调用了一个无效的方法,加个all exception breakpoint,看见crash在哪一行,估计是assetslibrary assetForURL:的问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问