我将尝试在运行时添加核心数据中的属性

时间:2017-07-06 06:04:09

标签: ios exception attributes entity

M尝试在运行时在核心数据中添加属性。 但是当我尝试执行代码时,它将返回如下错误:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Resgistration setProperties:]: unrecognized selector sent to instance 0x6080000a5400 请帮帮我。

NSEntityDescription *entity = [NSEntityDescription insertNewObjectForEntityForName:@"Resgistration" inManagedObjectContext:context];

//NSManagedObject *object = [[NSManagedObject alloc] init];
NSMutableArray *attribute = [[NSMutableArray alloc] init];
NSMutableArray *attribute1 = [[NSMutableArray alloc] init];

NSAttributeDescription *nameAttribute = [[NSAttributeDescription alloc] init];
[nameAttribute setName:@"lastAdd"];
[nameAttribute setAttributeType:NSStringAttributeType];
[nameAttribute setOptional:NO];
[nameAttribute setIndexed:YES];
[attribute addObject:nameAttribute];
[entity setProperties:attribute];
NSManagedObjectModel *objectModel = nil;
[attribute1 addObject:entity];
[objectModel setEntities:attribute1];

0 个答案:

没有答案