0

在我的应用程序中,我使用了以下代码和核心数据,

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface Adduser : NSManagedObject
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * password;
@property (nonatomic, retain) NSString * email;
@property (nonatomic, retain) NSString * contact_no;
@property (nonatomic, retain) NSString * address;
@property (nonatomic, retain) NSString * response;
@end

方法

-(IBAction)signup:(id)sender
{
Registration *adduser=[Registration new];//<-CoreData: error: Failed to call designated initializer on NSManagedObject class 'Registration'
adduser.name=txt1.text;
adduser.password=txt2.text;
adduser.email=txt3.text;
adduser.contact_no=txt5.text;
adduser.address=txtvu.text;
}

当我尝试实施时显​​示

CoreData: error: Failed to call designated initializer on NSManagedObject class 'Registration'

出现 SIGABRT 错误?我的代码有什么问题?请帮忙

4

1 回答 1

2

要创建托管对象类的实例,您需要:

Registration *adduser = [NSEntityDescription insertNewObjectForEntityForName:@"Registration" inManagedObjectContext:context];
于 2013-05-18T07:24:29.043 回答