views:

537

answers:

1

hi,

I submitted my app to iTunesConnect and Apple give me back the following crash report:

Thread 2 Crashed:
0   libobjc.A.dylib                 0x00003eb8 objc_msgSend + 16
1   Foundation                      0x0004c3aa _NSDescriptionWithLocaleFunc + 24
2   CoreFoundation                  0x0003d52e _CFStringAppendFormatAndArgumentsAux + 1390
3   CoreFoundation                  0x0003ceca _CFStringCreateWithFormatAndArgumentsAux + 66
4   CoreFoundation                  0x00073fd6 _CFLogvEx + 34
5   Foundation                      0x000661a4 NSLogv + 74
6   Foundation                      0x0006614a NSLog + 18
7   mobilescan                      0x00039014 -[BlaBlaBlaDao insertCategoryWithId:andName:] (BlaBlaBlaDao.m:110)

It seems that when the app tries to print the log, it make the application crashing. This is very strange because in debug mode, the app stopes 2 sec then print the error and keep working...

From the line 110 in the BlaBlaBlaDao.m where the application crash I have those lines:

NSLog(@"category, id:%@, name:%@", subcategory.id, subcategory.name);

 [subcategory addFreshfoodProductsObject:freshfoodProduct];

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

It comes from an Apple example...

Everyone knows why?

thanks for your help !

+2  A: 

In your format string, you are expecting two objects. For logging, an object's -description method is called. It looks like your application is crashing when trying to print the description of one of the objects. It may be that one or both of your properties are not objects, but scalar values instead. It's also possible that one of the properties, if it is an object, has been released at some point and you are messaging a deallocated instance.

Aside from the crashing, do not use NSLog in an application that you are submitting to the App Store. There is no reason for it to be there, and all it's doing is dumping text to the console of every iPhone running your application. If I'm not mistaken, all of that is being logged on each iPhone that would run this. Not only that, but it's slowing down your application unneccessarily. Either strip out these calls before you submit the application, or use #ifdef's to localize them to only your debug builds.

Brad Larson