UIDevice *device = [UIDevice currentDevice]; device.proximityMonitoringEnabled = YES;
BOOL state = device.proximityState;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChanged:) name:@"UIDeviceProximityStateDidChangeNotification" object:nil];
- (void) proximityChanged: (NSNotification *)note {
UIDevice *device = [note object];
NSLog(@"In proximity: %i", device.proximityState);
}If you want to start programming for the iPhone or iPod Touch, this book is the easy-to-follow guide you need. You'll learn hands-on all about Xcode suite of tools, the Objective-C programming language, and the core frameworks by writing sample apps. Before you know it, you'll not only have the skills to develop your own app, you'll also easily handle the complex details of preparing and submitting apps to the App Store.