Tips & Tricks
Everything you ever wanted to know but never dared to search for...

Open URL in a browser

using Cocoa (Mac Application):
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@""]];

using Cocoa Touch (iOS Application):
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""]];

Get an NSDictionary from a JSON response

NSData *jsonResults = [NSData dataWithContentsOfURL:url];
NSDictionary *pListResults = [NSJSONSerialization JSONObjectWithData:jsonResults
                                                         options:0 error:NULL];

Search in a NSString object

NSRange subRange = [str1 rangeOfString:@"tano"
                               options: NSCaseInsensitiveSearch];
if (subRange.location != NSNotFound) {
   NSLog(@"String is at index %lu, len=%lu",subRange.location,subRange.length);

Gaetano Causio © | Privacy Policy | Disclaimer