关于 NSLog 以及在哪里处理加载文件的问题

发布于 2024-10-23 21:47:35 字数 566 浏览 3 评论 0原文

在我的代码中,我正在使用 .txt 文件构建数据核心数据库。目前我在桌面上有该文件,并且有该文件的硬编码路径。我还使用 NSLog 语句跟踪数据库的负载,该语句在加载新数据库时显示在终端中。构建&分析指出我在 NSLog 的“存储到 xx 的值永远不会被读取”中用于跟踪的参数。但是,我确实在 NSLog 中使用 xx 来计算我正在加载的记录。

我在输入字段中使用一个秘密且非常长且特定的单词来启动数据库的加载。该字段通常用于其他用途。

我有以下问题:

  • “存储到 xx 的值从未被读取”是否被视为泄漏?我想不是。

  • 启动应用程序以使 NSLog 和 xx 仍在代码中时是否存在问题,或者我应该将其注释掉吗?

  • 我在苹果文档中读到,不允许在捆绑包之外引用,我想如果我想使用此方法,我也应该将 .txt 放入捆绑包中?

  • 由于我不希望 .txt 文件位于包中,管理数据库负载的建议是什么?我应该加载数据库,然后注释掉我发送到应用程序商店的代码中的所有相关代码,以删除应用程序外部的引用,还是有更好的方法?

干杯

In my code i am building a Data Core database out of a .txt file. Currently i have that file on the desktop and have a hard-coded path to that file. I am also tracking the load of the database with NSLog-statement that shows in the terminal when i load a new database. The build & analyze states that the parameters that i use for tracking in the NSLog's "Value stored to xx is never read". However, i do use xx in the NSLog to count the records i am loading.

I am using a secret and very long and specific word in an input field to start the load of the database. This field is normally used for something else.

I have the following questions:

  • Is the "Value stored to xx is never read" considered a leak? I guess not.

  • Is there a problem when launching the app to have the NSLog and the xx still in the code or should i commented it out?

  • I have read in Apples documentation that it is not allowed to reference outside of the bundle, i would guess that if i want to use this method i should place the .txt in the bundle as well?

  • As i do not want the .txt file to be in the package what is the recommendation for managing the load of the database? Should i load the database and then maybe commented out all related code in the code i ship to app-store to remove the references out side the app or is there a better way?

Cheers

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

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

发布评论

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

评论(1

嘴硬脾气大 2024-10-30 21:47:35
  • “永远不会读取存储到 xx 的值”消息

此消息不是泄漏。这暗示您将一个变量设置为一个值,然后永远不会读取该值(因此首先设置该变量是没有意义的)。示例:

- (void) fooFun {
    int i = 1;
    NSLog(@"Hello: %d", i);
    i = 3; // <- value stored to i is never read (thus this line is redundant)
    return;
}
  • 启动带有 NSLogs 的应用程序时出现问题

不,Apple 确实建议删除 NSLogs,但这不是必需的 AFAIK。我可能是错的,因为我使用的宏从发布版本中删除了所有 NSLog。 IIRC,这篇博客文章为我描述了它: http://www. karlkraft.com/index.php/2009/03/23/114/

  • 在包之外引用

这是一个奇怪的问题。如果您打算将您的应用程序放在应用程序商店中,其他人很可能会抢走它,但他们不会拥有您的文件。 iPhone 本身也无法访问您的桌面。不过,出于争论的目的,您可能会在应用程序中创建一个设置,让用户定义此文件所在位置的路径。

希望有帮助。

  • "Value stored to xx is never read" message

This message is not a leak. It's a hint that you're setting a variable to a value and then never, ever reading that value (thus setting the variable in the first place is meaningless). Example:

- (void) fooFun {
    int i = 1;
    NSLog(@"Hello: %d", i);
    i = 3; // <- value stored to i is never read (thus this line is redundant)
    return;
}
  • Problem when launching apps with NSLogs in them

No, Apple does recommend removing NSLogs but it's not required AFAIK. I may be wrong, as I am using a macro that removes all NSLogs from a release build. IIRC, this blog post described it for me: http://www.karlkraft.com/index.php/2009/03/23/114/

  • Referencing outside of the bundle

This is an odd question. If you intend to put your app on the app store, other people will most likely grab it and they won't have your file. Nor does the iPhone itself have access to your desktop. For argument's sake, though, you would probably create a setting in your app which let users define a path to where this file is located.

Hope that helps.

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