Optimizing CLLocationManager/CoreLocation to retrieve data points faster on the iPhone

I’ve had lots of issues with CLLocationManager on the iPhone also. From different Apps, and trial and error this is what I’ve figured out; 1) Use a singleton class for the locationManager, ONLY ONE Instance, follow the examples in: Apple’s LocateMe example Tweetero : http://tweetero.googlecode.com/svn/trunk I’m thinking you can only have one location manager running, … Read more

How to display the current project version of my App to the user?

After further searching and testing, I found the solution myself. NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSLog(@”%i Keys: %@”, [infoDictionary count], [[infoDictionary allKeys] componentsJoinedByString: @” ,”]); This snipplet gave me the following output: 20 Keys : NSBundleResolvedPath ,CFBundleVersion ,NSBundleInitialPath ,CFBundleIdentifier ,NSMainNibFile ,CFBundleIconFile ,CFBundleInfoPlistURL ,CFBundleExecutable ,DTSDKName ,UIStatusBarStyle ,CFBundleDevelopmentRegion ,DTPlatformName ,CFBundleInfoDictionaryVersion ,CFBundleSupportedPlatforms ,CFBundleExecutablePath ,CFBundleDisplayName ,LSRequiresIPhoneOS ,CFBundlePackageType ,CFBundleSignature … Read more

+[NSString stringWithString:] — what’s the point?

You might have a NSMutableString (or some home-grown NSString subclass) that you want to duplicate. NSMutableString *buffer = [NSMutableString string]; // do something with buffer NSString *immutableStringToKeepAround = [NSString stringWithString:buffer]; Of course, you can also just make a copy: NSMutableString *buffer = [NSMutableString string]; // do something with buffer NSString *immutableStringToKeepAround = [[buffer copy] autorelease]; … Read more

How to constrain autorotation to a single orientation for some views, while allowing all orientations on others?

The short answer is that you’re using UINavigationController, and that won’t work like you want it to. From Apple’s docs: Why won’t my UIViewController rotate with the device? All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set. To make sure that all your child view controllers rotate … Read more

difference between presentViewController and UINavigationController?

presentViewController offers a mechanism to display a so-called modal view controller; i.e., a view controller that will take full control of your UI by being superimposed on top of a presenting controller. UINavigationController offers a much more flexible mechanism where you can push a new controller, and later pop it, so to go back to … Read more

Refresh UIPageViewController – reorder pages and add new pages

I found a workaround to force UIPageViewController to forget about cached view controllers of neighboring pages that are currently not displayed: pageViewController.dataSource = nil; pageViewController.dataSource = self; I do this everytime I change the set of pages. Of course this doesn’t affect the currently displayed page. With this workaround I avoid the caching bug and … Read more

Email validation on textField in iOS

Use NSPredicate and Regex: – (BOOL)validateEmailWithString:(NSString*)email { NSString *emailRegex = @”[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}”; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@”SELF MATCHES %@”, emailRegex]; return [emailTest evaluateWithObject:email]; } For a bunch of emails separated by a comma: – (NSMutableArray*)validateEmailWithString:(NSString*)emails { NSMutableArray *validEmails = [[NSMutableArray alloc] init]; NSArray *emailArray = [emails componentsSeparatedByString:@”,”]; for (NSString *email in emailArray) { NSString *emailRegex = … Read more