NSLog 导致 iPhone 应用程序在 Apple 应用程序审核期间崩溃

发布于 2024-08-13 23:51:27 字数 1224 浏览 7 评论 0原文

我向 iTunesConnect 提交了我的应用程序,Apple 给我返回了以下崩溃报告:

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)

似乎当应用程序尝试打印日志时,它会使应用程序崩溃。 这很奇怪,因为在调试模式下,应用程序停止 2 秒,然后打印错误并继续工作...

从 BlaBlaBlaDao.m 中应用程序崩溃的第 110 行,我有这些行:

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

    [subcategory addFreshfoodProductsObject:freshfoodProduct];

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

它来自 Apple 示例。 ?

大家都知道为什么吗

感谢您的帮助 !

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 !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不忘初心 2024-08-20 23:51:27

在您的格式字符串中,您需要两个对象。对于日志记录,调用对象的 -description 方法。当尝试打印其中一个对象的描述时,您的应用程序似乎崩溃了。您的一个或两个属性可能不是对象,而是标量值。也有可能其中一个属性(如果它是一个对象)已在某个时刻被释放,并且您正在向已释放的实例发送消息。

除了崩溃之外,请勿在提交到 App Store 的应用程序中使用 NSLog。它没有理由存在,它所做的只是将文本转储到运行应用程序的每台 iPhone 的控制台。如果我没记错的话,所有这些都记录在每台运行此程序的 iPhone 上。不仅如此,它还会不必要地减慢您的应用程序的速度。在提交应用程序之前删除这些调用,或者使用 #ifdef 将它们本地化为仅您的调试版本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文