How to prevent your IOS app from going into sleeping mode using Objective-C

To prevent your IOS app from going into sleeping mode using Objective-C you can use the snippet below.

Sample Objective-C

How to reload a ViewController in IOS using Objective-C

To reload a UITableViewController in IOS using Objective-C you can simply use the reloadData method of the ViewController.

//MyTablViewController is a UITableViewController
[MyTableViewController.tableView reloadData] 

How to use substring in IOS using Objective-C

To use substring in IOS using Objective-C you can use the snippet below.

Sample Objective-C

NSString *myString = @"http://codesnippets.fesslersoft.de";
NSString *myNewString = [myString substringFromIndex:7]; //myNewString will be "codesnippets.fesslersoft.de"

How to clear notifications in IOS using Objective-C

To clear notifications in IOS using objective-c you can use the snippet below.

Sample Objective-C

//in method: application:didFinishLaunchingWithOptions
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

//in method: application:didReceiveRemoteNotification
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1]; //we need to to increment first
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];

How to set the ios bookmark icon in HTML

To set the ios bookmark icon in HTML you can use the following snippet.

Sample HTML

<link rel="apple-touch-icon" href="iOs_Icon.png"/>

If your icon is already glossy, you can prevent the device from adding its own gloss by using.

Sample HTML

<link rel="apple-touch-icon-precomposed" href="iOs_Icon.png"/>