These are our Top 10 reads of July 2015.
thanks to all visitors, bookmark us, share us, talk about us, Follow us!, Like us! let’s grow bigger! You can even participate in our Github Projects!
These are our Top 10 reads of July 2015.
thanks to all visitors, bookmark us, share us, talk about us, Follow us!, Like us! let’s grow bigger! You can even participate in our Github Projects!
To prevent your IOS app from going into sleeping mode using Objective-C you can use the snippet below.
1 2 |
[UIApplication sharedApplication].idleTimerDisabled = YES; // Turn off [UIApplication sharedApplication].idleTimerDisabled = NO; // Turn on |
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]
To hide the status bar while Splashscreen is Shown in IOS follow these Steps.
if you do not have the “Status bar is initially hidden” property, simply add it by selecting the last line in the File and then click the plus button on the right end of the line.
To show the status bar you can use this snippet.
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; //UIStatusBarAnimationNone, UIStatusBarAnimationFade or UIStatusBarAnimationSlide
To use substring in IOS using Objective-C you can use the snippet below.
NSString *myString = @"http://codesnippets.fesslersoft.de"; NSString *myNewString = [myString substringFromIndex:7]; //myNewString will be "codesnippets.fesslersoft.de"
labelTest.text = @"This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring.This is my Teststring."; labelTest.numberOfLines = 0; [labelTest sizeToFit];
To clear notifications in IOS using objective-c you can use the snippet below.
//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];
To format a float to 2 decimal places in Objective-C you can use the following snippet.
NSString* formattedVariable = [NSString stringWithFormat:@"%.02f", myFloatVariable];
To convert string to int using Objective-C you can use the snippet below.
[myString intValue];
or you can do it like this.
myString.intValue;