CoreData错误失败

时间:2013-05-18 04:42:00

标签: core-data ios6 nsobject

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

#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错误?我的代码有什么问题?请帮忙

1 个答案:

答案 0 :(得分:2)

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

Registration *adduser = [NSEntityDescription insertNewObjectForEntityForName:@"Registration" inManagedObjectContext:context];