I just started with CoreData yesterday, and I'm going crazy :( I created a project that uses CoreData (ticked the box -use CoreData). Created the entities, and then created the NSManagedObject classes for all the entities (I suppose they create the 'setter' and 'getter' methods for the entities).
Now, I #imported all these classes in my AppDeletegate and wrote this in my applicationDidFinishLaunching method:
(Subscriptions is one of the Entities in the application)
NSManagedObjectContext *context = [self managedObjectContext];
Subscriptions *sbs = (Subscriptions *)[NSEntityDescription insertNewObjectForEntityForName:@"Subscriptions" inManagedObjectContext:context];
[sbs setTitle:@"OK"];
[sbs setType:@"Tag"];
[sbs setCode:@"cars"];
NSError *error = nil;
if (![context save:&error]) {
NSLog(@"Couldn't create the subscription");
}
When I run this, I get this error
[NSManagedObject setTitle:]: unrecognized selector sent to instance 0x6160550
I have no idea why this is happening. Please Help!!! Thanks in advance to everyone!
Adding the header of Subscriptions
Subscriptions.h
@interface Subscriptions : NSManagedObject {
}
@property (nonatomic, retain) NSString * Type;
@property (nonatomic, retain) NSDecimalNumber * Read;
@property (nonatomic, retain) NSString * Title;
@property (nonatomic, retain) NSString * Code;
@property (nonatomic, retain) NSDecimalNumber * New;
@end
I didn't change anything. It's just as Xcode created it.