-1

NSLog documentation says:

Logs an error message to the Apple System Log facility.

Does this mean that if I want to test what my app does when killed, I can use XCode->Devices and look at the logs?

I am testing BLE state restoration, which supposedly restarts the app for a short amount of time when specific BLE events occur (see code below). However I am unable to see any messages in the device logs (see image below).

Am I missing something? How can I log these events?

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;
}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
mm24
  • 9,280
  • 12
  • 75
  • 170
  • If you connect your device to "iPhone Configuration utility" and check the console you can check the logs from device after killing the app also. I am not sure if you will be able to install it now or not on the new version of OSX but you can give it a try. It will also show you NSLog messages after your app is launched. (Device + App NSLog messages together) – Sneha Oct 15 '15 at 08:01
  • @sneha where can I download this "iPhone Configuration utility"? Is it a official tool a third party tool? – Otávio Oct 15 '15 at 08:30
  • It was a official tool from apple but they discontinued the version update but it still works. http://iphone-configuration-utility.soft32.com – Sneha Oct 15 '15 at 08:31

1 Answers1

0

I think you are not getting any data in "centralManagerIdentifiers". (centralManagerIdentifiers should be nil). And because of that the if condition is not getting executed.

And yes NSLog will definitely print log in Devices.

Try adding a test log outside if condition. it will be printed in device log for sure.

Alap Anerao
  • 2,083
  • 22
  • 27