Archive of iOS Development

Adding charts to your iPhone / iPad App using Core Plot 0.9

Posted by John Wordsworth on October 10, 2011 in iOS Development, OSX Development tagged with , , , ,

It's unfortunate that Apple do not provide a charting library bundled with their frameworks, for I suspect that would save many developers the trouble of finding a charting library and deciphering the documentation. I've come to the conclusion that CorePlot is the best bet at the moment - it's powerful and compatible with both iOS and OSX but unfortunately the documentation for isn't great. So, we're going to go through the process of adding a simple scatter chart to an iPad application.

Continue ReadingView Comments (52)

Wrapping Box2D Debug into a Cocos2D Layer

Posted by John Wordsworth on September 09, 2011 in iOS Development tagged with , , ,

When I first started integrating Box2D into my Cocos2D project, I found the whole process a little jarring. While I'd used C++ before, this was the first time I'd seen it mixed with Objective-C. This code snippet simply wraps the standard Box2D Debug calls from GLES-Render.h (included with Cocos2D) in it's own CCLayer, so that you can implement it quickly and easily. It also allows you to turn the layer on an off easily as you would any other CCLayer.

Continue ReadingView Comments (3)

iOS – performSelectorOnMainThread with Multiple Objects

Posted by John Wordsworth on August 08, 2011 in iOS Development tagged with , , ,

I recently ran into the situation where I wanted to call NSObject's performSelectorOnMainThread with multiple arguments. While it wasn't massively difficult, it was a bit more fiddly than I first expected - you have to get your hands dirty with NSInvocation. I've built a category that adds an additional method to NSObject which will allow you to call a performSelectorOnMainThread method with any number of objects as parameters. Feel free to use it in your own projects!

Continue ReadingView Comments (4)

Loading Cocos2D Sprite Frame Animations from Plist Files

Posted by John Wordsworth on July 07, 2011 in iOS Development tagged with , , ,

In a game that a friend and I are working on (Knight Terrors) we wanted a system to pre-load animations into CCAnimationFrameCache without having to hardcode any of that configuration. This means that our designer and artist, Jackson Matthews, can add and remove frames from a creature's animation without having to come back to me with a frame list to paste back into the code. I will assume you have knowledge of CCSpriteFrameCache and CCAnimations within cocos2d before embarking on this. If not, you can read up on them through the provided links.

Continue ReadingView Comments (4)

Overriding NSObject’s description

Posted by John Wordsworth on January 01, 2011 in iOS Development tagged with ,

NSObject is the base / root class for nearly every hierarchy of classes in Objective-C applications. NSObject provides the basic functionality that you take for granted when using Objective-C, such as providing the ability to retain and release objects. From first time iPhone developers to Objective-C gurus, it's hard to deny the usefulness of NSLog() and 'gdb> po' when trying to figure out just which part of your application is causing problems at a given time. NSLog works wonders for outputting strings combined with integers, floats etc. For ex

Continue ReadingLeave a Comment

In-App Email through MessageUI Kit

Posted by John Wordsworth on April 04, 2010 in iOS Development tagged with ,

I recently added the ability to an iPhone Application that we have been developing to allow the end-user to send email to their contacts directly from our application. This turned out to be trivial using the MessageUI Kit that Apple provide with the iPhone SDK. Here we detail how we implemented this in our application.

Continue ReadingView Comments (3)

Implementing a Singleton in Objective-C / iOS

Posted by John Wordsworth on April 04, 2010 in iOS Development tagged with ,

There are many pages of discussions around the internet about whether or not you should use global variables in your applications. I'm not going to to into the depths of these discussions, but I have come to live by the following ethos when it comes to using global variables in my application; Use them sparingly; Having too many global variables floating around makes it very hard to keep track of what's going on. I never use more than one global object for each logical section of my code - even if that object contains a handful of other objects from

Continue ReadingView Comments (31)

Launch Safari with UIApplication openURL

Posted by John Wordsworth on April 04, 2010 in iOS Development tagged with ,

Having devoted much of my time over the last few months developing for the iPhone, I thought it was time to start collecting a small library of useful code snippets here on my blog. I'm mostly posting these for my own use, so that I don't have to keep searching Google to keep finding the useful bits of code. However, I'll try to make the posts as accessible as possible, with some explanation where necessary. Launching Safari from within an iPhone App The openURL method of UIApplication is a very useful and valuable method. It provides a quick and

Continue ReadingView Comments (2)