I decided I’ve better jump in and get some hands on experience with IOS development. I’d read plenty about it but not had to build anything myself yet.

This appcoder “maze game” tutorial seems like a good starting place. It’s not an appropriate way to write a game, but it’s a simple intro to building an app.


Open XCode It needs to install new components.

I created a new project, single view application (instead of choosing a game…) Objective-C, iphone (noted quite a few differences in Xcode compared to the original article, but all pretty obvious to resolved)

Choose location and create git repo on remote server…

  • I created the repo on github first instead
  • Cloned it in CLI (as couldn’t get XCode to clone when starting a project, but it immediately recognised the local repo).

In Xcode set to Landscape right and disabled status bar

I had to use follow this article to create an empty white view controller as the xcode version had changed significantly since the appcoder demo was written: Creating Useful empty projects in Xcode

which I then gave a black background using the inspector view the view of ViewController.xib

Then added images to supporting files.

Then linked UIViews to IBOutlets and OBOutletCollection for the walls. The application no longer ran, after chasing down the error (NSUknownKeyException - very common with lots of causes - See Stack overflow, no connections were broken. Created a new (replacement) view controller and it was fixed okay. Seems to be be an error in the Xcode project config (caching) rather than an error in the nib (xib).

Add the CoreMotion and Quartz Core libraries via Build Phases link libraries

Update the AppViewController to set up the animation on the viewDidLoad invocation. I didn’t like appcoder’s approach so clean up the method a little. Learned the distinction between messages, methods and functions.

This was useful Objective C Methods This was useful Objective C Functions

Found that XCode refactoring is pretty limited compared to IntelliJ. Set up some better keybinding for refactoring. Refactoring in XCode

animiated gif of appcoder maze

Part 2

Hooking up the accelerators Appcoda part 2

Added the bunch of global properties to the view controller as suggested (these are silly, come back to fix them) and updated viewDidLoad to set up the CMMotionManager to populate a NSOperationQueue 60 times per second. Pretty straight forward.

Set up a block as the handler that records the acceleration and invokes the method to recalculate and repaint the pacman. The new position is calculated with a bit of trig, and pacman repainted by changing the coordinates of the UIImageView’s frame.

I would have liked to test by the IOS simulator doesn’t simulate the accelerometer. I couldn’t sign up as a developer either right now to use a real device. DUNS number is valid but missing information (D&B Australia need a fax sent to them). Individual sign up is broken. Annoyed.

IOS Developer error message

Sign-up was failing because the registration didn’t pick up my country from the Apple Id. I used the browser’s developer tools to enter “Australia” into the hidden country input and it got through. Now wait 2 days to see if it was accepted.

So, I’ll skipping testing with real device for now.

Adding rotation to the pacman is simple. It just extracts the angle from the velocity vector.

I’ve refactored the pacman model out to its class. It’s not perfect, but separates the math from the rendering (nearly, still coupled a bit tight).