Apple rejected app due to a crash which is not reproducing

空扰寡人 提交于 2019-12-24 23:25:24

问题


Apple provided the crash logs which explains the encountered exception and reason as below:

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Application Specific Information: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData dataUsingEncoding:]: unrecognized selector sent to instance 0x1b4c20'

Here are the lines of code highlighted as the reason of crash after symbolicting the crash logs

NSXMLParser *moveParser = [[NSXMLParser alloc] initWithData:[str_response dataUsingEncoding:NSUTF8StringEncoding]];

and

[[UAirship shared] registerDeviceToken:[deviceToken dataUsingEncoding:NSUTF8StringEncoding] withAlias:myAlias];

Apple has reviewed this app on iPhone 4 and iPad 3G with iOS version 5.1 and crash happens every time to them. Whereas we are unable to reproduce the crash on any platform. We have tried debugging on iPhone4, iPhone 3GS with iOS 5.1, iPhone 3GS with iOS 5.0, iPhone 3GS with iOS 4.3.2 but crash is not produced.

Can anyone let me know what is wrong with the code I am using?

Here is the block of code in which these lines are written.

NSString *str_response=(NSString *)[dic objectForKey:SuccessKey];
NSXMLParser *moveParser = [[NSXMLParser alloc] initWithData:[str_response dataUsingEncoding:NSUTF8StringEncoding]];
moveParser.delegate = self;
[moveParser parse];
[moveParser release];

and

NSString *deviceToken=[[NSUserDefaults standardUserDefaults] objectForKey:@"devToken"];
[[UAirship shared] registerDeviceToken:[deviceToken dataUsingEncoding:NSUTF8StringEncoding] withAlias:myAlias];

回答1:


It is possible that it has something to do with the plist (user defaults container). You try to register a deviceToken which may be NIL if devToken in standardUserDefaults is not set (empty or nonexistent plist-file). Try to delete all your plists in the Preferences folder and you'll probably reproduce the crash.

To solve the problem, you should check if deviceToken is NIL. If not: registerDeviceToken, otherwise create empty token etc.




回答2:


I think, its a clear issue of memory leak @ ** deviceToken**. Agree with @septi's description.

In exception clearly mentioned,'NSInvalidArgumentException', reason: '-[__NSCFData dataUsingEncoding:]: unrecognized selector sent and deviceToken might be storing null value and that is creating problem.




回答3:


Maybe your string str_response is not in memory due to autorelease

NSString *str_response= ([dic objectForKey:SuccessKey] : [[NSString alloc] initWithFormat:@"%@",[dic objectForKey:SuccessKey]] autorelease]  ?  "" );

NSXMLParser *moveParser = [[NSXMLParser alloc] initWithData:[str_response dataUsingEncoding:NSUTF8StringEncoding]];

moveParser.delegate = self;

BOOL isParsed = [moveParser parse];

if (isParsed) {

}else {

    // Parsing fail

}

[moveParser release];


来源:https://stackoverflow.com/questions/10347091/apple-rejected-app-due-to-a-crash-which-is-not-reproducing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!