1

在我的项目中,有时当调用 - (void)saveContext 时,应用程序崩溃,保持屏幕锁定,什么都做不了。

我发现在下面的函数 - (void)saveContext

 - (void)saveContext
{
    NSError *error = nil;
    NSManagedObjectContext *managedObjectContext = _dataController.managedObjectContext;
    if (managedObjectContext != nil) {

        if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {

             // Replace this implementation with code to handle the error appropriately.
             // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            abort();
        }
        else {

            NSLog(@"save successful?");
        }
    }

    if (error != nil) {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    }
}

没有输出消息。核心数据的保存功能没有成功,也没有失败的错误。为什么会这样?有人可以帮帮我吗?谢谢!


崩溃报告

Date/Time:       2013-10-03 18:05:31.016 +0800
OS Version:      iOS 6.1.3 (10B329)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread:  0

Elapsed total CPU time (seconds): 11.020 (user 11.020, system 0.000), 55% CPU 
Elapsed application CPU time (seconds): 9.389, 47% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libobjc.A.dylib                 0x3b8745ac objc_msgSend + 12
1   CoreData                        0x337f6bf4 -[NSSQLCore createAdapterOperationsForDatabaseOperation:] + 232
2   CoreData                        0x337f88c0 -[NSSQLCore performChanges] + 184
3   CoreData                        0x337f9a56 -[NSSQLCore saveChanges:] + 630
4   CoreData                        0x3376022a -[NSSQLCore executeRequest:withContext:error:] + 506
5   CoreData                        0x3375f4c4 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1300
6   CoreData                        0x337b76de -[NSManagedObjectContext save:] + 726
7   LFeCatalogue                    0x000ff130 -[AppDelegate saveContext] (AppDelegate.m:329)
8   LFeCatalogue                    0x00152432 -[ECatalogueDataController alertView:clickedButtonAtIndex:] (ECatalogueDataController.m:2316)
9   UIKit                           0x3591dc4c -[UIAlertView(Private) _buttonClicked:] + 292
10  UIKit                           0x358b10c0 -[UIApplication sendAction:to:from:forEvent:] + 68
11  UIKit                           0x358b1072 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
12  UIKit                           0x358b1050 -[UIControl sendAction:to:forEvent:] + 40
13  UIKit                           0x358b0906 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498
14  UIKit                           0x358b0dfc -[UIControl touchesEnded:withEvent:] + 484
15  UIKit                           0x357d95ec -[UIWindow _sendTouchesForEvent:] + 520
16  UIKit                           0x357c67fc -[UIApplication sendEvent:] + 376
17  UIKit                           0x357c6116 _UIApplicationHandleEvent + 6150
18  GraphicsServices                0x374d15a0 _PurpleEventCallback + 588
19  GraphicsServices                0x374d11ce PurpleEventCallback + 30
20  CoreFoundation                  0x33993170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
21  CoreFoundation                  0x33993112 __CFRunLoopDoSource1 + 134
22  CoreFoundation                  0x33991f94 __CFRunLoopRun + 1380
23  CoreFoundation                  0x33904eb8 CFRunLoopRunSpecific + 352
24  CoreFoundation                  0x33904d44 CFRunLoopRunInMode + 100
25  GraphicsServices                0x374d02e6 GSEventRunModal + 70
26  UIKit                           0x3581a2fc UIApplicationMain + 1116
27  LFeCatalogue                    0x000fdc72 main (main.m:16)
28  libdyld.dylib                   0x3bcb0b1c start + 0

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x3bd67648 kevent64 + 24
1   libdispatch.dylib               0x3bc97974 _dispatch_mgr_invoke + 792
2   libdispatch.dylib               0x3bc97654 _dispatch_mgr_thread$VARIANT$mp + 32

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x3bd66eb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bd67048 mach_msg + 36
2   CoreFoundation                  0x33993040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x33991d9e __CFRunLoopRun + 878
4   CoreFoundation                  0x33904eb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x33904d44 CFRunLoopRunInMode + 100
6   WebCore                         0x3990b500 _ZL12RunWebThreadPv + 440
7   libsystem_c.dylib               0x3bcd030e _pthread_start + 306
8   libsystem_c.dylib               0x3bcd01d4 thread_start + 4

Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib          0x3bd66eb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3bd67048 mach_msg + 36
2   CoreFoundation                  0x33993040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x33991d9e __CFRunLoopRun + 878
4   CoreFoundation                  0x33904eb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x33904d44 CFRunLoopRunInMode + 100
6   Foundation                      0x342513d0 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7   Foundation                      0x342d4e80 __NSThread__main__ + 968
8   libsystem_c.dylib               0x3bcd030e _pthread_start + 306
9   libsystem_c.dylib               0x3bcd01d4 thread_start + 4

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib          0x3bd77594 __select + 20
1   CoreFoundation                  0x339971f2 __CFSocketManager + 674
2   libsystem_c.dylib               0x3bcd030e _pthread_start + 306
3   libsystem_c.dylib               0x3bcd01d4 thread_start + 4

Thread 5:
0   libsystem_kernel.dylib          0x3bd77d98 __workq_kernreturn + 8
1   libsystem_c.dylib               0x3bcc5cf6 _pthread_workq_return + 14
2   libsystem_c.dylib               0x3bcc5a12 _pthread_wqthread + 362
3   libsystem_c.dylib               0x3bcc58a0 start_wqthread + 4

Thread 6:
0   libsystem_kernel.dylib          0x3bd77d98 __workq_kernreturn + 8
1   libsystem_c.dylib               0x3bcc5cf6 _pthread_workq_return + 14
2   libsystem_c.dylib               0x3bcc5a12 _pthread_wqthread + 362
3   libsystem_c.dylib               0x3bcc58a0 start_wqthread + 4

Unknown thread crashed with unknown flavor: 5, state_count: 1
4

0 回答 0