我解除存檔的NSFileWrapper數據下面的方法通常效果非常好:NSKeyedUnarchiver SIGBUS BUS_ADRALN崩潰
- (id)decodeObjectFromWrapperWithPreferredFilename:(NSString *)p {
NSFileWrapper *wrapper = [self.fileWrapper.fileWrappers objectForKey:p];
if (!wrapper) {
NSLog(@"Unexpected error: Couldn't find %@ in file wrapper!", p);
return nil;
}
NSData *data = [wrapper regularFileContents];
NSKeyedUnarchiver *unarchiver;
@try {
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
}
@catch (NSException *exception) {
NSLog(@"exception: %@", exception);
[TestFlight passCheckpoint:@"FILE LOADING EXCEPTION!"];
UIAlertView *alertOFF = [[UIAlertView alloc]
initWithTitle:@"Corrupt"
message:@"There was an error loading a file! Please contact [email protected]"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertOFF show];
}
return [unarchiver decodeObjectForKey:@"data"];
}
然而,我偶爾會得到一個SIGBUS崩潰的線unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
。我猜這種類型的異常沒有被我的異常處理程序捕獲?我該如何處理這些例外情況以及導致它們的原因?
這裏是Crashlytics崩潰報告:
Exception Type:SIGBUSCode:BUS_ADRALN
Thread 0 Crashed
Latest Crash: 11 September 2012 at 06:23
0 Foundation
-[NSKeyedUnarchiver initForReadingWithData:] + 389
1 Meernotes ✭ FRNBDocument.m line 221
-[FRNBDocument decodeObjectFromWrapperWithPreferredFilename:] + 221
2 Meernotes FRNBDocument.m line 155
-[FRNBDocument settings] + 155
3 Meernotes ModelController.m line 497
__39-[ModelController previewLoadDocAtURL:]_block_invoke_0 + 497
4
...
libdispatch.dylib
_dispatch_barrier_sync_f_slow_invoke + 78
5 libdispatch.dylib
_dispatch_main_queue_callback_4CF$VARIANT$up + 196
6 CoreFoundation
__CFRunLoopRun + 1268
7 CoreFoundation
CFRunLoopRunSpecific + 300
8 CoreFoundation
CFRunLoopRunInMode + 104
9 GraphicsServices
GSEventRunModal + 136
10 UIKit
UIApplicationMain + 1080
11 Meernotes main.m line 16
main + 16
此外,你應該改變 '返回[取檔decodeObjectForKey:@ 「數據」];'把這個對象在一個臨時的,然後發送一個取檔「finishDecoding」每類文檔信息,然後返回暫時的。 –
@DavidH好一點。我沒有讀過那遠了;-) –