Latest Articles

Use the navigation at the bottom to see older articles

Say hello to The WP Guru Podcast

Apple_Podcast_logo

This week I finally had a chance to prepare The WP Guru Podcast for you!

Get all my past, present and future screencasts delivered for free and automatically.

I’ve been planning this for years, and even though relatively simple to setup it took a bit of organisational efforts behind the scenes to make it happen. What this means is that when I record a screencast, you can now receive it via your favourite Podcast Catcher (such as iTunes).

Read more

How to run WordPress on your Laptop

In this new Podcast Season I will start things off by showing you how to run WordPress on your laptop. I will explain this on a Mac, but the process is very similar (if not identical) on a PC. All you need is an installer that gives you Apache, MySQL and PHP on your local … Read more

How to loop through every element in an NSArray

We can use something called Fast Enumeration for this, using a modified for loop: // build an array NSArray *myArray = [[NSArray alloc]initWithObjects:@”One”, @”Two”, @”Three”, @”Four”, nil]; // loop through every element (dynamic typing) for (id tempObject in myArray) { NSLog(@”Single element: %@”, tempObject); } You don’t have to use dynamic typing if you know […]

How to generate a random number in iOS

We can use the C function rand() for this: int i = rand()%10+1; NSLog(@”Random Number: %i”, i); This generates an integer between 1 and 10. Alternatively you can use the arc4random function: int i = arc4random() % 10; NSLog(@”Random Number: %i”, i); This will generate a random number between 0 and 9. One thing of […]

How to read the contents of a text file into an NSString

Imagine we had a file called myfile.txt which is a standard text file. On each line we have a new item we’d like to read so that our app can do something with it. Here’s how we do that: // get a reference to our file NSString *myPath = [[NSBundle mainBundle]pathForResource:@”myfile” ofType:@”txt”]; // read the […]

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).