【发布时间】:2015-10-15 07:50:20
【问题描述】:
NSLog 文档说:
将错误消息记录到 Apple 系统日志工具。
这是否意味着如果我想测试我的应用程序在被杀死时会做什么,我可以使用 XCode->Devices 并查看日志?
我正在测试 BLE 状态恢复,据说当特定 BLE 事件发生时,它会在短时间内重新启动应用程序(参见下面的代码)。但是,我无法在设备日志中看到任何消息(见下图)。
我错过了什么吗?如何记录这些事件?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The system provides the restoration identifiers only for central managers that had active or pending peripheral connections or were scanning for peripherals.
NSArray * centralManagerIdentifiers = launchOptions[UIApplicationLaunchOptionsBluetoothCentralsKey];
if (centralManagerIdentifiers != nil) {
for (int i=0; i<[centralManagerIdentifiers count]; i++) {
NSString * identifier = [centralManagerIdentifiers objectAtIndex:i];
NSLog(@"bluetooth central key identifier %@", identifier);
self.centralManagerDelegates = [BluetoothStatePreservationSync sharedInstance];
}
}
// Override point for customization after application launch.
return YES;
}
【问题讨论】:
-
如果您将您的设备连接到“iPhone 配置实用程序”并检查控制台,您还可以在终止应用程序后检查设备日志。我不确定你现在是否可以在新版本的 OSX 上安装它,但你可以试一试。它还会在您的应用程序启动后向您显示 NSLog 消息。 (Device + App NSLog 消息一起)
-
@sneha 我在哪里可以下载这个“iPhone 配置实用程序”?它是官方工具还是第三方工具?
-
这是苹果的官方工具,但他们停止了版本更新,但它仍然有效。 iphone-configuration-utility.soft32.com