2015-10-15 27 views
0

NSLog的文件說:理解的NSLog

記錄一個錯誤信息給蘋果系統日誌設施。

這是否意味着如果我想測試我的應用程序在殺死時(我知道聽起來很奇怪,但與我一起裸露),我可以使用XCode-> Devices並查看日誌?

我正在測試BLE狀態恢復,在特定的BLE事件發生時(據下面的代碼),這應該會在短時間內重新啓動應用程序。但是,我無法在設備日誌中看到任何消息(請參閱下圖)。

我錯過了什麼嗎?我怎樣才能記錄這些事件?

enter image description here

- (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; 
} 
+0

如果您將設備連接到「iPhone配置實用程序」並檢查控制檯,您也可以在殺死應用程序後檢查設備中的日誌。我不確定您是否可以在OSX的新版本上安裝它,但是您可以嘗試一下。它也會在您的應用程序啓動後向您顯示NSLog消息。 (設備+應用程序NSLog郵件在一起) – Sneha

+0

@sneha在哪裏可以下載此「iPhone配置實用程序」?它是官方工具第三方工具嗎? –

+0

這是來自蘋果的官方工具,但他們停止了版本更新,但它仍然有效。 http://iphone-configuration-utility.soft32.com – Sneha

回答

0

我覺得你是不是在 「centralManagerIdentifiers」 獲得的任何數據。 (centralManagerIdentifiers應該是零)。 因爲如此條件沒有得到執行。

是的NSLog肯定會打印登錄設備。

嘗試在條件之外添加測試日誌。它會被打印在設備日誌中。