I want to create a button,ie "Done",when pressed, save all the data into Core Data,I am using the codes below
- (IBAction)done:(id)sender
{
Player *player = [[Player alloc] init];
player.name = self.nameTextField.text;
player.game = game;
player.rating = 1;
[self.delegate playerDetailsViewController:self didAddPlayer:player];
NSManagedObjectContext *context = [self managedObjectContext];
Player *player = [NSEntityDescription
insertNewObjectForEntityForName:@"Player"
inManagedObjectContext:context];
player.name = self.nameTextField.text;
player.game = game;
player.rating = 1;
NSError *error;
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
}
but I keep getting errors like:
Semantic Issue: Use of undeclared identifier 'NSEntityDescription'; did you mean 'kSecAttrDescription'?
Receiver type 'PlayerDetailsViewController' for instance message does not declare a method with selector 'managedObjectContext'
Redefinition of 'player'
Use of undeclared identifier 'NSEntityDescription'; did you mean 'kSecAttrDescription'?
Bad receiver type 'CFTypeRef' (aka 'const void *')
Receiver type 'NSManagedObjectContext' for instance message is a forward declaration
Any ideas?
[xcode] Redefinition
turns up this question which will probably help you. But please don't ask us to fix all the errors in your code just because you didn't bother to look them up yourself. – Caleb