线程:NSPredicate中出现1个EXC_BAD_ACCESS

时间:2015-02-25 09:12:36

标签: ios objective-c macos core-data nspredicate

在我的Mac OS X应用程序中,我在Core Data部分(NSPredicate)中收到此 EXC_BAD_ACCESS 信号。

enter image description here

参考代码:

[self.managedObjectContext reset];

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

[self.managedObjectContext setMergePolicy:NSMergeByPropertyObjectTrumpMergePolicy];

//Setting Entity to be Queried
NSEntityDescription *entity = [NSEntityDescription entityForName:@"FileTable"
                                              inManagedObjectContext:self.managedObjectContext];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"_pk" ascending:NO]]];

[fetchRequest setEntity:entity];
NSError* error;

NSString *uuid = uniqueId;

NSPredicate *pred = [NSPredicate predicateWithFormat:@"uuid = %@", uuid];

[fetchRequest setPredicate:pred];

// Query on managedObjectContext With Generated fetchRequest
NSArray *fetchedRecords = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

// NSLog(@"fetchedRecords %@",fetchedRecords);

// Returning Fetched Records
return fetchedRecords;

我抓住了上述场景的堆栈跟踪

(
0   WEPA-PrintApp                       0x000000010a235969 WEPA-PrintApp + 47465
1   CoreFoundation                      0x00007fff9216acbc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
2   CoreFoundation                      0x00007fff9205c1b4 _CFXNotificationPost + 3140
3   Foundation                          0x00007fff8c528ea1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
4   AppKit                              0x00007fff8f95725b -[NSApplication _postDidFinishNotification] + 291
5   AppKit                              0x00007fff8f956fc6 -[NSApplication _sendFinishLaunchingNotification] + 191
6   AppKit                              0x00007fff8f953dc6 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 574
7   AppKit                              0x00007fff8f953805 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 244
8   Foundation                          0x00007fff8c548458 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 290
9   Foundation                          0x00007fff8c5482c9 _NSAppleEventManagerGenericHandler + 102
10  AE                                  0x00007fff9047a99c _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 531
11  AE                                  0x00007fff9047a719 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 31
12  AE                                  0x00007fff9047a623 aeProcessAppleEvent + 295
13  HIToolbox                           0x00007fff93e1b37e AEProcessAppleEvent + 56
14  AppKit                              0x00007fff8f94fec6 _DPSNextEvent + 2665
15  AppKit                              0x00007fff8f94efd0 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
16  AppKit                              0x00007fff8f942f73 -[NSApplication run] + 594
17  AppKit                              0x00007fff8f92e424 NSApplicationMain + 1832
18  WEPA-PrintApp                       0x000000010a250f96 WEPA-PrintApp + 159638
19  libdyld.dylib                       0x00007fff917ae5c9 start + 1
)

此崩溃并非始终发生。此处uuidNSString。任何人都可以提供解决方案来解决问题吗?

0 个答案:

没有答案