Pages

Wednesday, October 16, 2013

Few Useful Objective-C Snippets for an iOS App


LAUNCH MAIL AND SEND AN EMAIL

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://mymail@myserver.com"]];

PREVENT SLEEP MODE

[UIApplication sharedApplication].idleTimerDisabled = YES;

STOP RESPONDING TO TOUCHES

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

RESUME RESPONDING TO TOUCHES

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

DISPLAY AN ALERT WINDOW

UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@"Warning" message:@"too many alerts" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[alert show]