Can I programmatically clear my app’s notifications from the iOS 5 Notification Center?

To remove notifications from the Notification Center simply set your icon badge number to zero. [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; This only works if the number changes, so if your app doesn’t use the badge number you have to first set, then reset it. [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

Create UITextRange from NSRange

You can create a text range with the method textRangeFromPosition:toPosition. This method requires two positions, so you need to compute the positions for the start and the end of your range. That is done with the method positionFromPosition:offset, which returns a position from another position and a character offset. – (CGRect)frameOfTextRange:(NSRange)range inTextView:(UITextView *)textView { UITextPosition … Read more

How to get root view controller?

if you are trying to access the rootViewController you set in your appDelegate. try this: Objective-C YourViewController *rootController = (YourViewController*)[[(YourAppDelegate*) [[UIApplication sharedApplication]delegate] window] rootViewController]; Swift let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate let viewController = appDelegate.window!.rootViewController as YourViewController Swift 3 let appDelegate = UIApplication.shared.delegate as! AppDelegate let viewController = appDelegate.window!.rootViewController as! YourViewController Swift 4 & 4.2 … Read more

How to send multiple parameterts to PHP server in HTTP post

For the network operation these is better supporting API like AFNetworking available witch work async and way better to handle Tutorials for AFNetworking Get from here NSArray *keys = @[@”UserID”, ]; NSArray *objects = @[@(userId)]; NSDictionary *parameter = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL: [NSURL URLWithString:BaseURLString]]; [httpClient setParameterEncoding:AFJSONParameterEncoding]; [httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]]; NSMutableURLRequest … Read more