Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- NSLog(@"didFinishLaunching");
- // Get the device object and turn proximity monitoring on
- UIDevice *d = [UIDevice currentDevice];
- [d setProximityMonitoringEnabled:YES];
- // Get the NSNotificationCenter object
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- // Sign up to receive notifications when the proximity state changes
- [nc addObserver:self selector:@selector(proximityChanged:) name:UIDeviceProximityStateDidChangeNotification object:d];
- NSLog(@"Observing...");
- [self.window makeKeyAndVisible];
- return YES;
- }
- - (void)proximityChanged:(NSNotification *)note {
- // Print out the changes of proximity state
- NSLog(@"Proximity Changed: %d", [[note object] proximityState]);
- }
Add Comment
Please, Sign In to add comment