Core data 核心数据删除异常
我正在尝试清理状态为未完成的对象。然后我在从核心数据中删除这些对象时得到了delete异常。你能帮我指出错误吗?谢谢 代码如下:Core data 核心数据删除异常,core-data,Core Data,我正在尝试清理状态为未完成的对象。然后我在从核心数据中删除这些对象时得到了delete异常。你能帮我指出错误吗?谢谢 代码如下: - (void) cleanDownloadQueue { NSMutableArray *cleanedAssetFiles = [[NSMutableArray alloc] init]; //get objects from context NSError *error; NSFetchRequest *fetchRequest = [[NSFetchReque
- (void) cleanDownloadQueue {
NSMutableArray *cleanedAssetFiles = [[NSMutableArray alloc] init];
//get objects from context
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[self AssetFileEntityDescription]];
NSString *name = @"downloadStatus";
NSInteger value = COMPLETED;
NSPredicate *predicate =[NSPredicate predicateWithFormat:@"%K != %i",name,value];
[fetchRequest setPredicate:predicate];
NSArray *results = [[self.managedObjectContext executeFetchRequest:fetchRequest error:&error] mutableCopy];
//NSLog(@"current length results length: %i", [results count]);
if ([results count] > 0) {
for (NSObject *obj in results){
if ([obj isKindOfClass:[AssetFile class]]) {
AssetFile *assetFile = (AssetFile *) obj;
//assetFile.srAsset.assetFile = nil;
[cleanedAssetFiles addObject:assetFile];
}
}
}
[fetchRequest release];
[results release];
for (AssetFile *afile in cleanedAssetFiles) {
[self.managedObjectModel delete:afile];
}
if ([cleanedAssetFiles count] > 0) {
[self saveManagedObjectChanges];
}
[cleanedAssetFiles release];
}
下面是日志:
<Error>: -[NSManagedObjectModel delete:]: unrecognized selector sent to instance 0x1d8dd0
May 19 21:57:10 unknown DMC to Go[1182] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObjectModel delete:]: unrecognized selector sent to instance 0x1d8dd0'
*** Call stack at first throw:
(
0 CoreFoundation 0x32a9d64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x35475c5d objc_exception_throw + 24
2 CoreFoundation 0x32aa11bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x32aa0649 ___forwarding___ + 508
4 CoreFoundation 0x32a17180 _CF_forwarding_prep_0 + 48
5 DMC to Go 0x0000483f -[dmcIpadAppDelegate cleanDownloadQueue] + 934
6 DMC to Go 0x0001b617 +[DmcIpadAppDelegate cleanDownloadQueue] + 82
7 DMC to Go 0x0000b35d -[SRListViewController viewDidLoad] + 40
8 UIKit 0x3262cf0f -[UIViewController view] + 110
9 UIKit 0x3263b5ef -[UIViewController contentScrollView] + 22
10 UIKit 0x3263b45f -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 30
11 UIKit 0x3263b35d -[UINavigationController _layoutViewController:] + 24
12 UIKit 0x3263ae35 -[UINavigationController _startTransition:fromViewController:toViewController:] + 380
13 UIKit 0x3263ac43 -[UINavigationController _startDeferredTransitionIfNeeded] + 182
14 UIKit 0x3263ab87 -[UINavigationController viewWillLayoutSubviews] + 14
15 UIKit 0x3263ab23 -[UILayoutContainerView layoutSubviews] + 138
16 UIKit 0x325fb5fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
17 CoreFoundation 0x32a0af03 -[NSObject(NSObject) performSelector:withObject:] + 22
18 QuartzCore 0x35f3bbb5 -[CALayer layoutSublayers] + 120
19 QuartzCore 0x35f3b96d CALayerLayoutIfNeeded + 184
20 QuartzCore 0x35f3b8a7 -[CALayer layoutIfNeeded] + 78
21 UIKit 0x325fb5d7 -[UIView(Hierarchy) layoutIfNeeded] + 22
22 UIKit 0x326a3775 -[UIViewController window:willAnimateRotationToInterfaceOrientation:duration:] + 356
23 UIKit 0x326a2bc1 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 3100
24 UIKit 0x326a6677 -[UIWindow _setRotatableViewOrientation:duration:force:] + 54
25 UIKit 0x3263a8eb -[UIWindow _updateToInterfaceOrientation:duration:force:] + 74
26 UIKit 0x32639551 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 540
27 UIKit 0x326390ad -[UIWindow setDelegate:] + 168
28 UIKit 0x32638fa9 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 64
29 UIKit 0x32637611 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 460
30 UIKit 0x326165a7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 506
31 UIKit 0x3261632f -[UIView(Hierarchy) _postMovedFromSuperview:] + 106
32 UIKit 0x325fbc1b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 678
33 UIKit 0x325fb96b -[UIView(Hierarchy) addSubview:] + 22
34 UIKit 0x3262b35f -[UIWindow addRootViewControllerViewIfPossible] + 202
35 UIKit 0x3275653f -[UIWindow setRootViewController:] + 166
36 DMC to Go 0x00003055 -[dmcIpadAppDelegate application:didFinishLaunchingWithOptions:] + 792
37 UIKit 0x3262b821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
38 UIKit 0x32625b65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
39 UIKit 0x325fa7d7 -[UIApplication handleEvent:withNewEvent:] + 1114
40 UIKit 0x325fa215 -[UIApplication sendEvent:] + 44
41 UIKit 0x325f9c53 _UIApplicationHandleEvent + 5090
42 GraphicsServices 0x358d2e77 PurpleEventCallback + 666
43 CoreFoundation 0x32a74a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
44 CoreFoundation 0x32a7683f __CFRunLoopDoSource1 + 166
45 CoreFoundation 0x32a7760d __CFRunLoopRun + 520
46 CoreFoundation 0x32a07ec3 CFRunLoopRunSpecific + 230
47 CoreFoundation 0x32a07dcb CFRunLoopRunInMode + 58
48 UIKit 0x32624d49 -[UIApplication _run] + 372
49 UIKit 0x32622807 UIApplicationMain + 670
50 DMC to Go 0x00002927 main + 82
51 DMC to Go 0x000028d0 start + 40
:-[NSManagedObjectModel delete:]:发送到实例0x1d8dd0的选择器无法识别
5月19日21:57:10未知DMC要运行[1182]:***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[NSManagedObjectModel delete::]:未识别的选择器已发送到实例0x1d8dd0'
***第一次抛出时调用堆栈:
(
0 CoreFoundation 0x32a9d64f例外预处理+114
1 libobjc.A.dylib 0x35475c5d objc_异常_抛出+24
2 CoreFoundation 0x32aa11bf-[NSObject(NSObject)不识别选择器:+102
3 CoreFoundation 0x32aa0649 uuuuuuuuuuuuuuuuuu+508
4 CoreFoundation 0x32a17180\u CF\u转发\u准备\u 0+48
5 DMC转到0x0000483f-[dmcIpadAppDelegate cleanDownloadQueue]+934
6要转到的DMC 0x0001b617+[DmcIpadAppDelegate cleanDownloadQueue]+82
7 DMC转到0x0000b35d-[SRListViewController viewDidLoad]+40
8 UIKit 0x3262cf0f-[UIViewController视图]+110
9 UIKit 0x3263b5ef-[UIViewController内容滚动视图]+22
10 UIKit 0x3263b45f-[UINavigationController\u计算机和应用程序克隆内容插入的EltaForviewController:+30
11 UIKit 0x3263b35d-[UINavigationController\u layoutViewController:+24
12 UIKit 0x3263ae35-[UINavigationController\u开始转换:从ViewController:toViewController:+380
13 UIKit 0x3263ac43-[UINavigationController _StartDeferredTransition(如果需要)]+182
14 UIKit 0x3263ab87-[UINavigationController视图将布局子视图]+14
15 UIKit 0x3263B23-[UILayoutContainerView布局子视图]+138
16 UIKit 0x325fb5fb-[UIView(CALayerDelegate)布局层的子层:+26
17 CoreFoundation 0x32a0af03-[NSObject(NSObject)性能选择器:withObject:+22
18夸脱芯0x35f3bbb5-[CALayer布局子层]+120
19夸脱芯0x35f3b96d CalayerLayoutifNeed+184
20夸脱芯0x35f3b8a7-[需要加料层布局]+78
21 UIKit 0x325fb5d7-[需要UIView(层次结构)布局]+22
22 UIKit 0x326a3775-[UIViewController窗口:WillAnimateRotationInterfaceOrientation:duration:+356
23 UIKit 0x326a2bc1-[UIWindow\u setRotatableClient:TooOrientation:updateStatusBar:duration:force:+3100
24 UIKit 0x326a6677-[UIWindow\u setRotatableViewOrientation:持续时间:强制:][54
25 UIKit 0x3263a8eb-[UIWindow\u updateToInterfaceOrientation:duration:force:+74
26 UIKit 0x32639551-[UIWindow setAutorotates:forceUpdateInterfaceOrientation:+540
27 UIKit 0x326390ad-[UIWindow setDelegate:+168
28 UIKit 0x32638fa9-[UIViewController\u TryBecomerootViewController窗口:+64
29 UIKit 0x32637611-[UIVIEW控制器视图DIDMOVETOW:shouldApparOrdAppear:+460
30 UIKit 0x326165a7-[UIView(内部)\从窗口移动到窗口::+506
31 UIKit 0x3261632f-[UIView(层次结构)\u postMovedFromSuperview:+106
32 UIKit 0x325fbc1b-[UIView(内部)\ U addSubview:定位:相对位置::+678
33 UIKit 0x325fb96b-[UIView(层次结构)添加子视图:][22
34 UIKit 0x3262b35f-[UIWindow AddRootViewControllerServiceWifPossible]+202
35 UIKit 0x3275653f-[UIWindow setRootViewController:+166
36 DMC要转到0x00003055-[dmcIpadAppDelegate应用程序:didFinishLaunchingWithOptions:+792
37 UIKit 0x3262b821-[UIApplication-CallInitializationDelegatesForRL:有效负载:挂起:][772
38 UIKit 0x32625b65-[UIApplication\u runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:+272
39 UIKit 0x325fa7d7-[UIApplication handleEvent:withNewEvent:][1114
40 UIKit 0x325fa215-[UIApplication sendEvent:+44
41 UIKit 0x325f9c53 _UIApplicationHandleEvent+5090
42图形服务0x358d2e77紫色返回+666
43 CoreFoundation 0x32a74a97 \uuuu CFRUNLOOP \u正在调用\uu OUT \uu以执行\uu功能\uuuu+26
44 CoreFoundation 0x32a7683f\uuu CFRunLoopDoSource1+166
45芯基础0x32a7760d\uu CFRunLoopRun+520
46 CoreFoundation 0x32a07ec3 CFRunLoopRunSpecific+230
47 CoreFoundation 0x32a07dcb CFRUNLOOPSRUNINMODE+58
48 UIKit 0x32624d49-[UIU应用程序运行]+372
49 UIKit 0x3262807 UIApplicationMain+670
for (AssetFile *afile in cleanedAssetFiles) {
[afile.managedObjectContext delete:afile];
}