获取iOS中解析期间操作之间的时间间隔

发布于 2024-12-07 00:51:54 字数 219 浏览 0 评论 0原文

我正在解析 xml,我想知道如何跟踪执行相同操作所需的时间。

我尝试使用警报,但由于弹出大量警报,它一直使我的应用程序崩溃。

如果我尝试通过 XCODE 在 iPAD 上运行我的项目(即选择目标作为我的 iPAD),以及如果我尝试在 iPAD 未连接到 Mac 时运行该项目,情况是否相同?我问这个是因为,当我尝试 NSLogging 时,它会出现在 Xcode 上。但我觉得这样是不是不对。

I am parsing an xml and I would like to know how I can keep track of the time it takes to do the same.

I tried to use alerts, but it kept crashing my app due to the large number of alert popping up.

Is it the same if I try to run my project on my iPAD through XCODE (i.e. by selecting target as my iPAD) and if I try to run the project when the iPAD is not connected to the mac? I ask this because, when I try NSLogging the times, it comes out on the Xcode. But I feel that is it not right.

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

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

发布评论

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

评论(2

垂暮老矣 2024-12-14 00:51:54

NSLog 应该在 XCode 中显示。它将日志消息打印到系统日志中,而在 iPad 上,您无法在设备本身上看到该消息。

如果是我,我会这样做:

在解码 XML 之前存储一个 NSDate 变量(可能作为属性,因为您很可能异步进行 XML 解码)

self.timingDate = [NSDate date];

然后,当 XML 完成解码时:

NSLog(@"Time taken: %f", [[NSDate date] timeIntervalSinceDate:self.timingDate]);

将打印输出解码所花费的时间(以秒为单位)。

NSLog is supposed to show in XCode. It prints a log message to the system log, which, on the iPad you have no way of seeing on the device itself.

If it were me, I'd do something like this:

Store an NSDate variable before decoding the XML (probably as a property, since you're most likely doing XML decoding asynchronously)

self.timingDate = [NSDate date];

Then, when the XML has finished decoding:

NSLog(@"Time taken: %f", [[NSDate date] timeIntervalSinceDate:self.timingDate]);

That will print out the amount of time spent decoding in seconds.

北方的巷 2024-12-14 00:51:54

您可以使用 NSLog 并在未连接到 XCode 机器时运行它。之后,您可以将其连接到 XCode 并读取断开连接时所做的控制台条目。只需转到管理器并选择您设备的控制台即可。

编辑:您还可以通过从 App Store 安装控制台应用程序来查看设备本身上的 NSlog 条目。

You can use NSLog and run it while not connected to your XCode machine. Afterwards, y0u can connect it to XCode and read the console entries made while it was disconnected. Just go to the organizer and select your device's console.

edit: You can also see the NSlog entries on the device itself by installing the Console app from the App Store.

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