2016-05-18 56 views
0

我尝试在App Store中发布应用程序,但是我得到了Apple团队的响应,该应用程序崩溃。我使用Crashlytics,所以我得到了具体的崩溃线。 我无法复制崩溃 - 在设备上或模拟器中。Apple Review拒绝NSBundle异常

此代码应计算md5静态资源总和以确保没有人更改它们。

代码:

NSArray *formats = @[@"html", @"mustache", @"strings", @"p12", @"xml", @"der", @"nss", @"css", @"json", @"plist"]; 
NSArray *filesToSkip = @[@"Info.plist"]; 

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *resourcePath = [bundle resourcePath]; 
NSFileManager *man = [NSFileManager defaultManager]; 
NSArray *resPaths = [man subpathsAtPath:resourcePath]; 
resPaths = [resPaths sortedArrayUsingSelector:@selector(compare:)]; 
NSMutableArray *sums = [NSMutableArray array]; 
for(NSString *path in resPaths) { 
    if([filesToSkip containsObject:[path lastPathComponent]] == NO && [formats containsObject:[path pathExtension]]) { 
     NSString *fullPath = [resourcePath stringByAppendingPathComponent:path]; 
     NSData *content = [NSData dataWithContentsOfFile:fullPath]; 
     NSString *md5 = [content md5]; 

     [sums addObject:md5]; //line of crash - inserting nil element into the NSMutableArray 
    } 
} 

md5方法,如果从这里:https://stackoverflow.com/a/16391701/5226328 - 当NSData对象是零收益为零。

它试图找到问题,但我不知道什么是要去:

我无法找到任何情况下,这将使md5(串)零(甚至捆绑==零或resourcePath ==零它不应该在该行崩溃)。

我想我错过了什么(或不明白Apple Review方法)。任何帮助或建议,将不胜感激。

回答

0

您不能使用方法addObject将nil添加到NSMutableArray中。或者,您可以尝试在MD5方法返回nil时随时向数组添加[NSNull null]。在后面的代码中,当你使用NSMutableArray时,你还需要检查NSNull对象并将它们解释为nil。

这里是一个类似的帖子:how to add nil to nsmutablearray?

+0

谢谢你的回答。我知道我不能将nil添加到NSMutableArray。但是提供的代码不应该试试这个。要添加零“resurcePath”或“路径”必须是零 - 但是然后for-in不会被执行。另一种可能性 - 'fullPath'不指向任何文件。但它也不太可能 - 路径是早些时候获得的。 我知道它不能为零。但我不知道它有多可能是零。 – franiis

相关问题