How to Open the SMS App With a Phone Number

Dec 24, 2009   //   by Derek van Vliet   //   Development  //  No Comments

It’s the day before Christmas, so this is the last post in our advent tip series. We’ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they’ve helped you in developing your iPhone apps. This may be the last blog post in this series, but you can be sure we’ll still be writing about our adventures with iPhone, cocos2d and OpenFeint development.

Less Yap, More Tip

Today’s advent tip is how to open the Messages app (aka the SMS app) with a specific phone number populated in the To: field. This is accomplished with great ease because the iPhone has implemented the sms: URI scheme. Therefore, we can use the UIApplication class’ openURL method, which we have seen before when we discussed how to dial a phone number, pre-compose an email, and yes, even open a URL.

So here it is: the one line of code you need to pop open the SMS app with a phone number:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:5555555555"]];

How to Suspend Touch Input

Dec 23, 2009   //   by Derek van Vliet   //   Development  //  No Comments

Have you ever encountered a situation where you wish you could just pause and resume touch input while developing an iPhone app? Sure, you could always increase the complexity of your input handling by considering the state of any number of variables, but there are some times when just switching input off and on would be easiest.

We had a number of cases like this when developing Addicus. In particular, because we have both the game and game over screens operating in a single cocos2d scene, we were noticing some bugs that occurred because of the way we handled input. This was solved by suspending input for brief periods of time.

Input Goes Off

Here’s how to tell your iPhone app to stop responding to touch events in just one line of code:

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

Input Goes On

And as you might expect, resuming responding to touch input events is similarly easy:

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

Addicus Now On Sale for $1.99 – Just in Time For Christmas!

Dec 23, 2009   //   by Derek van Vliet   //   Announcements  //  No Comments


In celebration of the season, we’re happy to announce that Addicus is now on sale for the extra low price of $1.99.

The reviews have been piling up and the consensus is in: Addicus is a must-have puzzle game for the iPhone.

If you’re doing some last minute Christmas shopping on the app store, or if you’re looking for the best puzzle game to load onto your freshly unwrapped iPhone, then look no further than Addicus.

Merry Christmas from Get Set Games!


How to Log to the Console Using NSLog

Dec 22, 2009   //   by Derek van Vliet   //   Development  //  1 Comment

Xcode has a built in console that provides an invaluable debugging tool for iPhone app development. It gives you a way to monitor text output from your app live at runtime. It works both for apps being debugged in the simulator and on a device.


Logging statements to the console is just as easy as you would expect it to be in iPhone app development. Just run the NSLog function like so:

NSLog(@"hello world");

Format Specifiers

The NSLog statement also supports string formatting specifiers, so you can also output the values of variables to the console with just one line. Below are some examples:

NSString * str = @"hello world";
NSLog(@"%@", str);
int num = 10;
NSLog(@"%i", num);
float price = 1.99;
NSLog(@"%f", price);

How to Upgrade Your iPhone Game to OpenFeint 2.4

Dec 21, 2009   //   by Derek van Vliet   //   Development  //  1 Comment

If you were watching twitter this week, you might have heard that OpenFeint 2.4 was quietly released to developers. This update surely stretches the definition of “point release” because it is packed with awesome new features as well as a complete overhaul of the interface.

If you are upgrading to OpenFeint 2.4 from a previous version, then it is not as easy as replacing the source code. However, it is still quite easy to make the upgrade if you just keep a few things in mind. Here’s what you need to know:

Disabling Chat

If you were previously disabling the chat feature in order to meet a certain parental ratings requirement, then you would be doing so by passing the OpenFeintSettingDisableChat setting into the initializeWithProductKey method. Since chat is not the only user-genereated content in OpenFeint 2.4, this setting name has been changed to OpenFeintSettingDisableUserGeneratedContent. Below is the new way to initialize OpenFeint with chat (and all user-generated content) disabled:

NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
			[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight], OpenFeintSettingDashboardOrientation,
			@"Addicus", OpenFeintSettingShortDisplayName,
			[NSNumber numberWithBool:YES], OpenFeintSettingDisableUserGeneratedContent,
OFDelegatesContainer* delegates = [OFDelegatesContainer containerWithOpenFeintDelegate:self
[OpenFeint initializeWithProductKey:@"MY_PRODUCT_KEY"

New Library Dependencies

If you replaced OpenFeint 2.3.x in your project with the new 2.4 source, you might have gotten a bunch of nasty errors upon building it. This is because the OpenFeint 2.4 requires more libraries to be added to your target. You need to add the following 3 frameworks to your target to get your OpenFeint 2.4 game to build successfully:

  • CFNetwork
  • CoreLocation
  • MapKit

Achievements and Social Networks

In OpenFeint 2.4, unlocking an achievement no longer prompts the user to notify their friends on Twitter and Facebook by default. However, you can restore this behaviour by setting the OpenFeintSettingPromptToPostAchievementUnlock setting to be true at the time of initialization. Below is how to initialize OpenFeint 2.4 with prompts to post achievements to social networks enabled:

NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
			[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight], OpenFeintSettingDashboardOrientation,
			@"Addicus", OpenFeintSettingShortDisplayName,
			[NSNumber numberWithBool:YES], OpenFeintSettingPromptToPostAchievementUnlock,
OFDelegatesContainer* delegates = [OFDelegatesContainer containerWithOpenFeintDelegate:self
[OpenFeint initializeWithProductKey:@"MY_PRODUCT_KEY"

How to Play a Video With MPMoviePlayerController

Dec 20, 2009   //   by Derek van Vliet   //   Development  //  6 Comments

Splash screens, cutscenes, tutorials or just good old content. There are plenty of reasons to need to play a video in your iPhone app. Here’s how to do it in 3 simple steps:

1. Add the MediaPlayer framework to your target.

2. Import the MediaPlayer header file in the file you intend to begin playing the video in, like so:

#import <MediaPlayer/MediaPlayer.h>

3a. Now we can stream a video from the internet like so:

NSURL *url = [NSURL URLWithString:@""];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[player play];

3b. Alternately, we can stream a video that you include in your app bundle. To stream a file called myvideo.m4v, you would run the following code:

NSString *path = [[NSBundle mainBundle] pathForResource:@"myvideo" ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[player play];

How to Format an NSString

Dec 19, 2009   //   by Derek van Vliet   //   Development  //  2 Comments

It’s back to basics with today’s advent tip. I would be surprised if anything short of ALL developers have had a need to format strings at one time or another. iPhone app development is no exception.

String formatting allows you to build a string based on a template and varying types of values. For example, if I am keeping track of a player’s score as an integer and I want to display a string to the player that celebrates their score by saying “You scored 2600! Way to go!”, then I need string formatting to get the correct score in the middle of that string.

How to Do It

Below is an example of how to build the above NSString. This example formats a string with an integer in it using the %i format specifier.

int score = 2600;
NSString * scoreString = [NSString stringWithFormat:@"You scored %i! Way to go!",score];

Format Specifiers

But string formatting doesn’t stop at putting integers in strings. Below are some of the most common format specifiers for other value types:

Specifier Purpose
%i integer
%f float
%@ Objective-C object (commonly used to specify another NSString)
%x hexadecimal

How to Take the Shine off Your App’s Icon

Dec 18, 2009   //   by Derek van Vliet   //   Development  //  1 Comment

Screen shot 2009-12-18 at 4.56.39 PMiPhone apps have a curved shine applied to their icons by default. It makes any icon look like it has been buffed to a high gloss. But what if you don’t want your icon to look shiny? What if you want full control over the look of your icon? Don’t fret: there are a couple of easy ways to disable the shine and take back control, and they’re both rather easy.


Screen shot 2009-12-18 at 4.45.15 PMThe first method is to add a setting to your project in Xcode. Just follow these 4 simple steps to do so:

1. Open your iPhone app’s info.plist file.

2. Command-click and select Add Row.

3. Select “Icon already includes gloss and bevel effects” from the drop down that appears.

4. Check the checkbox that appears next to the new row.

Alternately, you could set this setting in your info.plist by editing it in a text editor. You just need to add the following 2 XML tags inside the <dict> tag:


How to Prevent the iPhone from Sleeping

Dec 17, 2009   //   by Derek van Vliet   //   Development  //  No Comments


Left idle, the iPhone goes into sleep mode after about a minute. This narcoleptic behaviour saves on battery life, but there are situations where you would not want the device to go to sleep. For instance, in the middle of a multiplayer game that is turn-based, such as chess. You could wait for longer than a minute for your opponent to make make their move and you wouldn’t want to miss it when they did.

To keep the iPhone awake and alert, simply run the following line of code:

[UIApplication sharedApplication].idleTimerDisabled = YES;

Do use this tip sparingly though. The iPhone’s power is unmatched, to be sure, but unfortunately it is not unlimited.

How to Show the Network Activity Indicator

Dec 16, 2009   //   by Derek van Vliet   //   Uncategorized  //  1 Comment

Screen shot 2009-12-16 at 10.14.26 PMThe network activity indicator is like the UIActivityIndicatorView we previously discussed, only it sits on the status bar, it is smaller, and believe it or not, it is even easier to manipulate. It’s the little rotating wheel of bars (pictured right) that shows up on the status bar whenever your iPhone is accessing the network.

Show It

If you would like to let your users know that your iPhone app is currently swapping data with the network, you can do so with this simple line of code:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

Hide It

You guessed it: once you’re done showing it, to hide it again, just set the same UIApplication property to NO like so.

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

Our Games

Latest Tweets