菜鸟教程小白 发表于 2022-12-12 10:21:03

ios - 恢复过去的 NSLog


                                            <p><p>几天前,使用我的应用程序的测试人员遇到了一个看似不可重现的错误。我相信我的应用程序记录的 NSLogs 可能会提供有关该问题的信息,但 Xcode Organizer 控制台仅记录 260 左右的先前行。设备上是否有一些日志文件可以提供更多的 NSLog?测试人员有越狱设备,因此访问根目录应该不是问题。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>为什么不使用 PList 来存储日志? </p>

<p>我开发了一些基于位置的应用程序。我总是要绕着某个区域开车来测试<strong>Location Update</strong>、<strong>Region Monitoring</strong>等的准确性。我将这些日志存储到一个PList中,然后我会分析这些日志在我完成运行后在 PList 上。 </p>

<p>示例代码:</p>

<pre><code>-(void)addLocationToPList{

NSString *plistName = ;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = ;
NSString *fullPath = ;

NSMutableDictionary *savedProfile = [ initWithContentsOfFile:fullPath];

if (!savedProfile){
    savedProfile = [ init];
    self.shareModel.myCurrentLocationArray = [init];
}
else{
    self.shareModel.myCurrentLocationArray = ;
}

if(self.shareModel.myBestLocationDictFromTracker)
{
      ;
      ;
}

if (! ) {
    NSLog(@&#34;Couldn&#39;t save Location.plist&#34; );
}
}
</code></pre>

<p>每当有位置更新时,我都会调用上述函数将位置添加到 PList。您可以根据您真正需要记录的内容以任何方式使用它。</p>

<p>我认为它比管理器控制台日志要好得多,因为您可以提取 PList Out 并在您的 Mac 上保留一份副本以供将来分析等。我正在使用 <a href="http://www.i-funbox.com/ifunboxmac/" rel="noreferrer noopener nofollow">iFunBox</a>访问/提取 PList。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 恢复过去的 NSLog,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24028626/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24028626/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 恢复过去的 NSLog