Globas techn
Globas techn

Reputation: 95

CoreData error failed

In my application i have used following code with core data,

#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

Method

-(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;
}

When i try to implement is shows the

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

with SIGABRT error?what wrong with my code?Please help

Upvotes: 0

Views: 58

Answers (1)

Wain
Wain

Reputation: 119021

To create an instance of a managed object class you need to:

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

Upvotes: 2

Related Questions