我已经在这个问题上苦苦挣扎了一段时间,但我似乎无法足够准确地重现它来描述确切的用例。本质上,我正在做的是发出打开本机 iOS 6.0 Facebook 共享对话框的请求(使用 Facebook iOS SDK 3.1.1):
if ([[SocialManager sharedManager] isNativeFacebookShareDialogAvailable]) {
if (!url) {
url = [NSURL URLWithString:@""];
}
if (!imageUrl) {
imageUrl = [NSURL URLWithString:@""];
}
dispatch_async(backgroundQueue, ^{
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = [UIImage imageWithData:imageData];
if (!image) {
image = [[UIImage alloc] init];
}
if ([FBNativeDialogs canPresentShareDialogWithSession:[FBSession activeSession]]) {
dispatch_async(dispatch_get_main_queue(), ^{
[FBNativeDialogs presentShareDialogModallyFrom:sender initialText:initialText images:@[image] urls:@[url] handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
failBlock([[error userInfo] description]);
} else {
if (result == FBNativeDialogResultSucceeded) {
completionBlock();
} else if (result == FBNativeDialogResultCancelled) {
failBlock(@"User cancelled");
} else if (result == FBNativeDialogResultError) {
failBlock(@"Unknown error");
}
}
}];
});
} else {
LogErr(@"Can't display native share dialog for active session");
}
});
}
在presentShareDialogModallyFrom:sender
被调用之后,我要么得到以下崩溃日志:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x1d161490> was mutated while being enumerated.'
*** First throw call stack:
(0x32ede2a3 0x326b097f 0x32eddd85 0x35da094d 0x32edb62f 0x35da07f5 0x35e7e5e5 0x35e0ccd7 0x35e0cb6d 0x372c490f 0x35e0ca61 0x35e160d5 0x372b783b 0x35e160b1 0x372b711f 0x372b699b 0x372b6895 0x372c5215 0x372c53b9 0x36f5fa11 0x36f5f8a4)
libc++abi.dylib: terminate called throwing an exception
或者我没有崩溃,并且本机共享对话框按原样出现。
堆栈意味着在此时调用的线程上调用UIRemoteViewControllerCreationRequest
,这里有两个不同崩溃的示例:
谢谢你的帮助