tags:

views:

136

answers:

0

I'm developing an application using Core Data. I want to save multiple values in the database and I used the code snippet:

Event *event = (Event *)[NSEntityDescription insertNewObjectForEntityForName:@"Event" 
                                                      inManagedObjectContext:managedObjectContext];

[event setLatitude:[NSNumber numberWithDouble:coordinate.latitude]];
[event setLongitude:[NSNumber numberWithDouble:coordinate.longitude]];
[event setCreationDate:[NSDate date]];
[event setName:@"iPhone"];

NSError *error = nil;
if (!**[managedObjectContext save:&error]**) {
    //Handle the Error
}

But I can't save the context. Please send me a solution.