How to create an NSTimer

Timers are good if you want to delay executing a method, or if you need to call a method repeatedly. To set a one-off timer without setting a property you can use this: // calls the updateLabel method in 5 seconds [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updateLabel) userInfo:nil repeats:NO]; However, you won’t be able to stop it […]

How to update jQuery Mobile in Dreamweaver CS6

Adobe_Dreamweaver_CS6_IconSince the release of Adobe’s Dreamweaver CS6 the jQuery and jQuery Mobile libraries have been updated. This means that when you create a new Mobile Starter page, you’ll get outdated libraries by default.

With a bit of hacking we can change this to the most current version though. Let me show you how it worked for me – many thanks to Greg’s article on how to do this in Dreamweaver CS5.5.

Read more

How to save a UIImage

// let’s save our image as a JPG NSData *imageData = UIImageJPEGRepresentation(chosenImage, 1); // get our home directory and add the save path and file name NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@”Documents/myImage.jpg”]; // then write the file to disk [imageData writeToFile:imagePath atomically:YES];

How to combine NSString objects

Say you had two NSString objects, firstString and secondString and you’d like to combine them into a new string called comboString. You can use the convenience method stringWithFormat for this: NSString *comboString = [[NSString alloc]initWithFormat:@”First %@ and second %@”, firstString, secondString]; Any variable is passed at the end of the string, replacing each %@ symbol.

How to create a PhoneGap project for Xcode 4.5

Once you’ve downloaded the latest version from http://phonegap.com, unZIP it and copy the resulting folder to a safe directory (i.e. don’t leave it in your Downloads folder… duh!) You’ll create a fully fledged Xcode project from the command line. Make sure you cd into the directory where the create script resides. Contrary to the “Getting […]