Reputation: 3402
I have bad access issue in core data while insert data in database and I also used @try,@catch block but I can't find any solution for the same. I am stuck for last 3days so please help me for solve this issue or give me any suggestion.
- (BOOL) addSynchedContactsList:(int)aAppContactId :(NSString*)aDevContactId
{
NSManagedObjectContext *context = [[PFCoreDataController sharedCoreDataController] managedObjectContext];
BOOL success = YES;
ContactsListSync *syncContact = (ContactsListSync *)[NSEntityDescription insertNewObjectForEntityForName:ENTITY_CONTACTSLISTSYNC inManagedObjectContext:context];
syncContact.appContactlistId = [NSNumber numberWithInt:aAppContactId];
syncContact.devConatctlistId = aDevContactId;
return success;
}
In this line,
ContactsListSync *syncContact = (ContactsListSync *)[NSEntityDescription insertNewObjectForEntityForName:ENTITY_CONTACTSLISTSYNC inManagedObjectContext:context];
OR
ContactsListSync *syncContact = (ContactsListSync *)[[NSEntityDescription insertNewObjectForEntityForName:ENTITY_CONTACTSLISTSYNC inManagedObjectContext:context] retain];
So Please give me any suggestion or any idea.
Thanks in advance for help.
Upvotes: 0
Views: 324
Reputation: 4214
Put a break point at the first line and step through each. I would be checking for the following:
Check ContactListSync Entity for required fields not provided?
If it is failing at the third line, seems would be one of three things, context invalid, context on another thread, entity name incorrect. What clues do you get in the error message at exception?
Upvotes: 1