我有一个 JSON 响应,我把它变成了这样的字典:
NSError *error;
self.restKitResponseDict = [NSDictionary dictionaryWithDictionary:[NSJSONSerialization JSONObjectWithData:response.body options:0 error:&error]];
我有一个具有以下属性/属性的核心数据类:
name
image_url
当我restKitResponseDict
从上面记录时,我看到它image_url
被列为"image_url"
如下:
name = Rock;
"image_url" = "http://f.cl.ly/items/122s3f1M1E1p432B211Q/catstronaut.jpg";
这就是KVC崩溃的原因吗
[CoreDataClass setValuesForKeysWithDictionary:self.restKitResponseDict];
像这样:
'[<CoreDataClass 0x14132c> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image_url.'
引号重要吗?我应该要求我的服务器人员摆脱可能导致它的下划线吗?
核心数据类:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface CoreDataClass : NSManagedObject
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * image_url;
@end
@implementation CoreDataClass
@dynamic name;
@dynamic image_url;
@end