Tips for Getting Started with iOS

I’ve had quite a few developers ask me for tips on getting started with iOS. The following are the tips and resources I wish I knew about before starting my own journey with iOS. Keep in mind that in building an iPhone or iPad app there are 2 technologies you need to master: iOS – […]

Tags: iOS, Objective-C

C99 Initializer Syntax in Objective C

This week a colleague sent me a snippet of Objective-C syntax I had never seen before. self.imageView.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f), .size=image.size}; This is (apparently) called C99 Initializer Syntax. This type of syntax can be used to initialize any struct in C (and Objective C) which is especially useful when working with CGRect and CGPoint. The […]

Tags: iOS, Objective-C

The Problem with Interface Builder

Most iOS developers seem to have a love-hate relationship with Interface Builder: they will either use Interface Builder for everything or completely avoid it and do everything in code. Example Let’s take a look at a simple example where using Interface Builder can be painful. I’m going to create a simple view in Interface Builder […]

Tags: iOS, Objective-C

Using Multiple ViewControllers on a Single Screen in iOS

In the world of iOS we usually stick with a single ViewController per screen. In fact, this is so common that many developers are not even aware that it’s possible to use more than one ViewController on a single screen. I’m going to run through a quick example and then highlight some of the benefits […]

Tags: iOS, Objective-C

Record and Playback Audio in iOS

On my last iPad project we needed the ability to record a sound clip and then play it back to the user with some visualizations. This is relatively easy with AVFoundation, but – as with many things in iOS – it takes quite a bit of boilerplate code to get it working. Recording To get […]

Tags: iOS, Objective-C

Thoughts on Parse

Parse is a cloud-based storage framework for iOS applications. Parse supplies an SDK for your application that allows you to easily push and pull data from the cloud-based platform that they provide for you – it’s all included. With any kind of persistence on a mobile device comes the obvious problem of offline support – […]

Tags: iOS, Objective-C

Literals in Objective C

Objective C is not a pure Object-Orientated language, which means you often need to convert between primitive/basic types (like char or int) and objects (like NSValue or NSNumber). This is usually rather tedious and results in large amounts of boilerplate code. animation.fromValue = [NSNumber numberWithDouble:0.0]; animation.toValue = [NSNumber numberWithDouble:2*M_PI]; This is especially true when dealing […]

Tags: iOS, Objective-C

Extending classes in Objective C using Categories

Yesterday I had to perform the simple task of shuffling an array in Objective C. There is unfortunately no built-in method to do this (which is a bit strange) which meant I really wanted a way to add a shuffle method to the NSArray class. In C# I would use an extension method to do […]

Tags: iOS, Objective-C

Perform an action after a delay in iOS

Today I had to perform an action (play a sound file) when a user touches a button, but only do so after half a second had passed. Luckily iOS has very good support for this. [self performSelector:@selector(playAudio) withObject:nil afterDelay:0.5f]; This is a method on NSObject which also has a bunch of similar methods for all […]

Tags: iOS, Objective-C

Logging a Frame in iOS

It happens quite often that you need to log the dimensions of a frame in iOS (which is a CGRect struct). Because you need to log 4 different values, it’s quite clunky. NSLog(@”Frame is {{%g, %g}, {%g, %g}}”, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); Turns out, there’s a much easier way. NSLog(@”Frame is %@”, NSStringFromCGRect(frame)); Happy coding.

Tags: iOS, Objective-C