我在我的项目中使用 Core Data 并在以下代码部分中遇到了罕见的崩溃
-(void) useDocument{
AFFormsCoreDataEngine* engine = [AFFormsCoreDataEngine sharedInstance];
if (![[NSFileManager defaultManager] fileExistsAtPath: [engine.formsDatabase.fileURL path]])
{
[engine.formsDatabase saveToURL: engine.formsDatabase.fileURL forSaveOperation: UIDocumentSaveForCreating completionHandler: ^(BOOL success){
// setup
}];
}
else if (engine.formsDatabase.documentState == UIDocumentStateClosed)
{
[engine.formsDatabase openWithCompletionHandler: ^(BOOL success){
// setup
}];
}
else if (engine.formsDatabase.documentState == UIDocumentStateNormal)
{
// setup
}
}
这是崩溃日志所说的:
Last Exception Backtrace:
0 CoreFoundation 0x371fd88f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x31272259 objc_exception_throw + 33
2 CoreFoundation 0x371fd789 +[NSException raise:format:] + 1
3 Foundation 0x32ce83a3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 91
4 UIKit 0x306b3149 -[UIDocument openWithCompletionHandler:] + 173
5 EETECH 0x00014d23 -[AFFormListViewController useDocument] (AFFormListViewController.m:150)
谁能帮我解决这个问题?它很少发生,但仍然很不愉快