1

I'm writing an app that communicate with a server. The server uses json, so I take this json in my app and I serialize the result into a NSMutableDictionary that then is used to create a new entity.

This is the code :

if (context == nil) {
    context = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}

UserTable *ut = [NSEntityDescription insertNewObjectForEntityForName:@"UserTable" inManagedObjectContext:context];
ut.user = [Diz objectForKey:@"user"];
ut.email = [Diz objectForKey:@"email"];
ut.phone = [Diz objectForKey:@"phone"];

NSError *error = nil;    
if (![context save:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);        
}

All works perfectly in iOS 4.3, iOS 6.0 and 6.1. In iOS 5.0.1 this code causse an exc_bad_Address localized in [context save:&error] or localized sometimes in ut.phone=[Diz objectForKey:@"phone"].

I'm using only one context (I have test threading composition with "isMainThread" function), What I can do? My error log is empty,the app simply does a crash.

EDIT

Thanks for the suggestions. I'm already removing my app from the device, but i'll try to do a migration. I have enabled exception breakpoint, but it's the same... The app crash without log any error (i have also NsZombie enabled). During the crash the green breakpoint is setted on an attribute of the Entity "UserTable" ,if i remove this attribute from saving the breakpoint is setted in the save function.

EDIT

After many tests i have detect a standard behavior for this crash. My Entity UserTable has 31 attributes, if i delete one attribute all works correctly... i have already tried to recreate the entity with another name and with others attribute's name but the behavior is the same... What does it means? There's a limit for entity's attributes number? Any other suggestions?

cri1682
  • 442
  • 6
  • 17

1 Answers1

0

Without further details it's difficult to understand what is going on.

Few suggestions in the meantime.

First. Provide some useful info about your Core Data model. Maybe, it's just a supposition, you've changed something in the model and now you need to remove the app already installed or perform a migration.

Second. Enable exceptions to see what happens Here you can follow this discussion "Run > Stop on Objective-C exception" in Xcode 4?.

Third. Use camelCase notation. Diz should be diz or a more explicit name like resultDictionary or whatever you want.

Fourth. Are you sure that a single context it is correct? When you have a lot of data to download from the server, the UI could freeze.

Finally, it could be better to a have a log of the error. What does it mean that this is empty?

Community
  • 1
  • 1
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190