- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个讨厌的错误,如果能给我指明解决方案的大体方向,我将不胜感激。有时,我会收到以下异常,该异常与在我的核心数据模型中的 3 个不同的 NSManagedObject 子类上调用 initWithCoder 有关。如果我从我的设备中删除应用程序并重新加载它,或者在模拟器上重置内容,异常就会消失。在我的代码中,我没有在 NSManagedObject 子类上显式调用 initWithCoder。
该错误似乎是在编辑我的源代码的随机部分后随机出现的。关于从哪里开始的任何想法?
2014-01-11 15:59:22.078 Flip Evaluator and Manager[354:a0b] -[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80
2014-01-11 15:59:22.079 Flip Evaluator and Manager[354:a0b] CoreData: error: exception during fetchRowForObjectID: -[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80 with userInfo of (null)
2014-01-11 15:59:22.081 Flip Evaluator and Manager[354:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SellingCosts initWithCoder:]: unrecognized selector sent to instance 0xc2cec80'
*** First throw call stack:
(
0 CoreFoundation 0x01e9a5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c1d8b6 objc_exception_throw + 44
2 CoreFoundation 0x01f37903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01e8a90b ___forwarding___ + 1019
4 CoreFoundation 0x01e8a4ee _CF_forwarding_prep_0 + 14
5 Foundation 0x01830b2a _decodeObjectBinary + 3498
6 Foundation 0x0182fc15 _decodeObject + 340
7 Foundation 0x0182fab9 -[NSKeyedUnarchiver decodeObjectForKey:] + 181
8 Foundation 0x018a168d +[NSKeyedUnarchiver unarchiveObjectWithData:] + 106
9 Foundation 0x018202e5 -[_NSKeyedUnarchiveFromDataTransformer transformedValue:] + 47
10 CoreData 0x0064bd09 _prepareResultsFromResultSet + 4105
11 CoreData 0x00649583 newFetchedRowsForFetchPlan_MT + 1795
12 CoreData 0x0063448e -[NSSQLCore newRowsForFetchPlan:] + 526
13 CoreData 0x0065302e -[NSSQLCore fetchRowForObjectID:] + 1198
14 CoreData 0x00650798 -[NSSQLCore newValuesForObjectWithID:withContext:error:] + 296
15 CoreData 0x00650667 -[NSPersistentStoreCoordinator(_NSInternalMethods) newValuesForObjectWithID:withContext:error:] + 71
16 CoreData 0x0064fa3b _PFFaultHandlerLookupRow + 411
17 CoreData 0x0064f897 -[NSFaultHandler fulfillFault:withContext:forIndex:] + 39
18 CoreData 0x0064f473 _PF_FulfillDeferredFault + 259
19 CoreData 0x0064f2c6 _sharedIMPL_pvfk_core + 70
20 CoreData 0x00653cd5 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) _genericValueForKey:withIndex:flags:] + 85
21 CoreData 0x0068d781 _PF_Handler_Public_GetProperty + 161
22 CoreData 0x0068d685 -[NSManagedObject valueForKey:] + 149
23 Flip Evaluator and Manager 0x00030c4c -[OzCalculator sumTheValuesInSet:withAttributeKeyForValue:] + 428
24 Flip Evaluator and Manager 0x0002f7d5 -[OzCalculator sumMoreCostsAndUpdateDataModelFor:] + 165
25 Flip Evaluator and Manager 0x0002edc1 -[OzCalculator performAllCalculationsOnProperty:] + 817
26 Flip Evaluator and Manager 0x00002d37 -[OzPropertyConverter createAManagedPropertyFromAnEvaluatedProperty:] + 1175
27 Flip Evaluator and Manager 0x00041233 -[OzHaveYouPurchasedThisProperty goForwardToNextView] + 307
28 libobjc.A.dylib 0x01c2f874 -[NSObject performSelector:withObject:withObject:] + 77
29 UIKit 0x0098d0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
30 UIKit 0x0098d04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
31 UIKit 0x00a850c1 -[UIControl sendAction:to:forEvent:] + 66
32 UIKit 0x00a85484 -[UIControl _sendActionsForEvents:withEvent:] + 577
33 UIKit 0x00a841fd -[UIControl touchesBegan:withEvent:] + 254
34 UIKit 0x009ca34b -[UIWindow _sendTouchesForEvent:] + 386
35 UIKit 0x009cb184 -[UIWindow sendEvent:] + 1232
36 UIKit 0x0099ee86 -[UIApplication sendEvent:] + 242
37 UIKit 0x0098918f _UIApplicationHandleEventQueue + 11421
38 CoreFoundation 0x01e2383f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
39 CoreFoundation 0x01e231cb __CFRunLoopDoSources0 + 235
40 CoreFoundation 0x01e4029e __CFRunLoopRun + 910
41 CoreFoundation 0x01e3fac3 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x01e3f8db CFRunLoopRunInMode + 123
43 GraphicsServices 0x02c2a9e2 GSEventRunModal + 192
44 GraphicsServices 0x02c2a809 GSEventRun + 104
45 UIKit 0x0098bd3b UIApplicationMain + 1225
46 Flip Evaluator and Manager 0x0002e5dd main + 141
47 libdyld.dylib 0x030c1725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
代码:
//
// SellingCosts.h
// Flip Evaluator and Manager
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class Cost, Property, TotalCosts;
@interface SellingCosts : NSManagedObject
@property (nonatomic, strong) NSNumber * deedPrep;
@property (nonatomic, strong) NSNumber * realtyCommisionAmount;
@property (nonatomic, strong) NSNumber * realtyCommisionPercent;
@property (nonatomic, strong) NSNumber * totalCost;
@property (nonatomic, strong) NSSet *moreCosts;
@property (nonatomic, strong) Property *property;
@property (nonatomic, strong) TotalCosts *totalCosts;
@property (nonatomic, strong) NSNumber * transferTaxAmount;
@property (nonatomic, strong) NSNumber * transferTaxPercent;
@property (nonatomic, strong) NSNumber *totalIncompleteCost;
@property (nonatomic, strong) NSNumber *totalCompleteCost;
@end
这是在出错之前调用的方法:
-(NSInteger)sumTheValuesInSet:(NSMutableSet *)set withAttributeKeyForValue:(NSString *)attributeKey
{
NSInteger sumToReturn = 0;
for (id obj in set) {
sumToReturn = sumToReturn +[[obj valueForKey:attributeKey] integerValue];
}
return sumToReturn;
}
该方法通过 NSSet
[sellingCosts valueForKey:@"moreCosts"]
中的 Cost
对象进行枚举。
这是Cost
对象的模型//
// Cost.h
// Flip Evaluator and Manager
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class BuyingCosts, HoldingCosts, SellingCosts, OtherCosts, TotalCosts;
@interface Cost : NSManagedObject
@property (nonatomic, strong) BuyingCosts *buyingCosts;
@property (nonatomic, strong) HoldingCosts *holdingCosts;
@property (nonatomic, strong) SellingCosts *sellingCosts;
@property (nonatomic, strong) OtherCosts *otherCosts;
@property (nonatomic, strong) NSString * name;
@property (nonatomic, strong) TotalCosts *incompleteCosts;
@property (nonatomic, strong) TotalCosts *completedCosts;
@property (nonatomic, strong) NSNumber *complete;
@property (nonatomic, strong) id costType;
@property (nonatomic, strong) NSNumber *amount;
@end
最佳答案
分享你的模型,乍一看这似乎是一个转换问题。
您还应该在 -sumTheValuesInSet:withAttributeKeyForValue:
中共享代码,因为这似乎是您代码中出现问题之前的最后一点。
关于ios - NSManaged 对象 initWithCoder 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21067982/
我有一个实体,其属性 value 类型为“Double”。为什么,当我为此创建一个 NSManagedObject 子类时,它会更改为 NSNumber 吗? @NSManaged var value
我正在尝试转换 Apple's sample code用于为核心数据创建自定义部分标识符,以便将 TableView 中的部分从 Objective-C 正确排序/标记到 Swift 中。他们为声明为
我在各种场合都遇到过这个关键字。我有点知道它应该做什么。但我真的很想更好地理解它。 我注意到 @NSManaged - 不是基于文档,而是通过重复使用: 它神奇地取代了键值编码。 大致相当于Objec
我在应用程序商店中有一个名为 Hapistats 的应用程序。它使用cloudkit。我正在将所有数据从 cloudkit 转换为 Coredata。 我有一个名为log的实体,它与activity具
我从核心数据中获取了一些记录,并将其呈现在表格 View 中。所有这些记录都有 11 个属性。现在,在我的表格 View 演示文稿中,我在标题上添加了一个用于所有这些属性的按钮。单击按钮后,我想根据该
我有一个具有两个关系的 NSManagedObject 类:courseA 和 courseB。这些关系应该用动态变量表示。如何从类外部更改此变量? @objc(Universtity) pu
我有以下核心数据属性 @NSManaged public var part: [Int]? 它可能包含 0 或 1 或两者。我正在尝试过滤掉包含 1 的 part 并执行此操作 fetchReque
我正在使用 UITextView 控件实现 NSUndoManager。如果我想撤消最后的文本更改,我可以用 // NSUndoManager *myUndoManager; Declared in
我正在向现有数据集添加新属性。如果我从 Parse.com 后端获得的该属性的值不存在,我需要采取纠正措施(例如将其设置为默认值)。我已经查看了此处发布的各种解决方案,但它们不起作用,我已将 Xcod
我在类中声明了一个变量,如下所示: @NSManaged var isFavorite: Bool 我想声明一个属性观察者,与下面的非常相似。 var organization: String {
我有一个 NSManagedObjects 数组,它由几个片段共享,一些在主队列上,一些在回调闭包中。有时,当我清除这个数组时,代码的其他部分会尝试访问它以在 UI 上读取和显示数据,但有时找不到数据
Xcode 可以从核心数据实体生成这个: // This file was automatically generated and should not be edited. import Foun
所以我读了很多关于 @NSManaged 的文章,很多人说它与 Objective-C 中的 @dynamic 属性相同。有人还说,基本上机器代码需要在正常代码的编译时出现,但是使用 NSMana
我有一个讨厌的错误,如果能给我指明解决方案的大体方向,我将不胜感激。有时,我会收到以下异常,该异常与在我的核心数据模型中的 3 个不同的 NSManagedObject 子类上调用 initWithC
我想初始化“Item”类中的变量,就像变量“Item2”类中的变量 这是“Item”类:- import UIKit import CoreData import SwiftyJSON class I
我有 NSObject 类名 TrackInfo,它包含轨道信息,如名称、艺术家姓名、缩略图等。 我使用这个类作为下载数据,解析数据后将信息保存到那个类中。现在我有另一个选项卡,我必须在其中显示一些数
我正在将用 Swift 编写的项目转换为使用 CoreData。一切正常,除了现在我正在尝试将自定义类转换为 NSManagedObject 类以将其属性存储在 CoreData 中。它看起来像这样:
我在一个更大的项目中遇到问题,并将其归结为这个简单的代码。出于演示目的,我在 Model.swift 文件中创建了一个新的 Swift 项目: import Foundation import Cor
我使用 Swift。我有一个 CoreData,它有一个名为 days 的字符串属性。我想为此分配一个默认值。我在我的 CoreData 模型类中尝试过它,但它给出了一个错误,提示 “NSManage
我有一个名为 Attendee 的 PFObject 子类。在这个类中,有一个实例变量,我称之为 isFavorite。下面是它的类定义: @NSManaged var isFavorite: Boo
我是一名优秀的程序员,十分优秀!