How to delete a file

Once you have a reference to the file in question you can call the removeItemAtPath method: // get reference with path and filename NSString *filePath = [[NSString alloc]initWithFormat:@”Documents/myFile.txt”]; NSString *deleteThis = [NSHomeDirectory()stringByAppendingPathComponent:filePath]; // now delete the file [[NSFileManager defaultManager]removeItemAtPath:deleteThis error:nil]; This does not work with wildcards in the file name (for example *.jpg).

How to access the iPhone Simulator Directory Structure

You can see the full directory under ~Library/Application Support/iPhone Simulator You’ll be presented with a list of iOS Versions, each of which has several folders to explore. To access data that your apps have written, head over to Applications and see a list of cryptic folders, each one corresponding to one of your apps. In […]

How to test if a file exists

Imagine we had a file that we’ve saved: NSString *myFile = [NSHomeDirectory() stringByAppendingPathComponent:@”Documents/myFile.txt”]; Before accessing it we can determine if it exists or not: BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:[NSHomeDirectory()stringByAppendingPathComponent:myFile]];

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