Mobile Development

iPhone

Restrictions for AdHoc Testing

Another wise move by Apple to frustrate and alienate it’s developers. Thanks a lot Apple.

In short you can now only register 100 AdHoc devices per year, not at any one time. Why the hell did they change that? If anything, we’re all begging for more AdHoc versions!!

How on earth can you run a large scale beta test of a game with the current system? Answer: You can’t.

Check out this post for a full explanation:

The rules surrounding adding devices have changed

Learning OpenGL

Jeff LaMarche (who’s blog you should definitely be following), has posted some useful intro tutorials on OpenGL.

You might find them useful if your new to OpenGL and trying to get to grips with it.

Check them out here.

F1 Insider now available!

F1 Insider, our latest iPhone app for Formula 1 has just been released!

Check it out: http://www.f1insider.co.uk/download/

The Formula 1 2009 Season is coming!

We just submitted F1 Insider to Apple, so it should hopefully be available for purchase on the App Store early next week.

F1 Insider brings all the latest information on the 2009 Formula 1™ Season to your finger tips. Follow the F1 Insider team as we go through what looks set to be the most exciting Formula 1™ World Championship to date!

You can find more information at the official website: http://www.f1insider.co.uk

Redline released

We’ve just released Redline, our first iPhone app based on our own IP.

Check it out on the AppStore!

iPhone Ad Hoc Code signing Gotchas

Theres a few gotchas with code signing which I’ve found can result in errors when installing an Ad Hoc application onto a user’s iPhone through iTunes, usually of the sort: “Application Redline was unable to be installed on the iPhone (Mitch iPhone) because it could not be verified”.

This error is really a generic error that says the iPhone could not verify the code signature, and so didn’t complete installing.

Things to double check:

  1. Bundle Identifier is correct and matches with the one selected in the Provisioning Profile.
  2. The deviceID has been correctly added to the Provisioning Profile.
  3. The Entitlements.plist file has been added to the project (see the howto doc on Distribution profiles). This is what catches most people out, since you don’t need it for development.
  4. Ensure the get-task-allow check box is unticked in the Entitlements.plist
  5. The Provisioning Profile has been dragged into iTunes as well as the .app or .ipa file.

Also, for AdHoc distribution, I’d recommend packaging up the .app as an ipa file. This is better compatability for windows, because a .app file is a just a folder, and it also allows the iTunesArtwork to be displayed.

At Greenius we use a simple script to package up an AdHoc build. Note you should edit the variables at the top for the appname and the build folder. Later I plan to update this so its a bit more flexible and can take the options from the command line. It also expects a iTunesArtwork.png file for the iTunesArtwork, which should be a 512×512 png.

Download adhocpackage script

Dynamic multi-line UILabel

Quick tip if you want a dynamic multi-line UILabel (i.e you don’t know how many lines there will be), just use this:

myLabel.numberOfLines = 0;

Easy!

Strange IB error

Just a tip, if you are using IBOutlets and seperate nib files, if you get a strange error like this:

*** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[<UIViewController 0x44e8b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewA.’

Check that the controller class is set correctly for both the Controller in the main file, and the File Owner in the Nib file you are referencing.

This error seems to happen when you link a nib file to a controller in IB, and the class types do not match. Strangley the error only happens when you link an IBOutlet inside that controller though!

This thread describes the problem and solution a little:

http://forums.macrumors.com/archive/index.php/t-576991.html

iPhone UIFont List

Here is a list of fonts available on the iPhone with UIFont.

Font Family: American Typewriter
Font: AmericanTypewriter
Font: AmericanTypewriter-Bold

Font Family: AppleGothic
Font: AppleGothic

Font Family: Arial
Font: ArialMT
Font: Arial-BoldMT
Font: Arial-BoldItalicMT
Font: Arial-ItalicMT

Font Family: Arial Rounded MT Bold
Font: ArialRoundedMTBold

Font Family: Arial Unicode MS
Font: ArialUnicodeMS

Font Family: Courier
Font: Courier
Font: Courier-BoldOblique
Font: Courier-Oblique
Font: Courier-Bold

Font Family: Courier New
Font: CourierNewPS-BoldMT
Font: CourierNewPS-ItalicMT
Font: CourierNewPS-BoldItalicMT
Font: CourierNewPSMT

Font Family: DB LCD Temp
Font: DBLCDTempBlack

Font Family: Georgia
Font: Georgia-Bold
Font: Georgia
Font: Georgia-BoldItalic
Font: Georgia-Italic

Font Family: Helvetica
Font: Helvetica-Oblique
Font: Helvetica-BoldOblique
Font: Helvetica
Font: Helvetica-Bold

Font Family: Helvetica Neue
Font: HelveticaNeue
Font: HelveticaNeue-Bold

Font Family: Hiragino Kaku Gothic ProN W3
Font: HiraKakuProN-W3

Font Family: Hiragino Kaku Gothic ProN W6
Font: HiraKakuProN-W6

Font Family: Marker Felt
Font: MarkerFelt-Thin

Font Family: STHeiti J
Font: STHeitiJ-Medium
Font: STHeitiJ-Light

Font Family: STHeiti K
Font: STHeitiK-Medium
Font: STHeitiK-Light

Font Family: STHeiti SC
Font: STHeitiSC-Medium
Font: STHeitiSC-Light

Font Family: STHeiti TC
Font: STHeitiTC-Light
Font: STHeitiTC-Medium

Font Family: Times New Roman
Font: TimesNewRomanPSMT
Font: TimesNewRomanPS-BoldMT
Font: TimesNewRomanPS-BoldItalicMT
Font: TimesNewRomanPS-ItalicMT

Font Family: Trebuchet MS
Font: TrebuchetMS-Italic
Font: TrebuchetMS
Font: Trebuchet-BoldItalic
Font: TrebuchetMS-Bold

Font Family: Verdana
Font: Verdana-Bold
Font: Verdana-BoldItalic
Font: Verdana
Font: Verdana-Italic

Font Family: Zapfino
Font: Zapfino

Gotcha with Obj-C properties

Properties in Objective-C can be quite useful sometimes, but you have to be careful because they don’t always work how you think they should. Here is a common gotcha among people new to Obj-C and properties.

Consider we have a class called Sprite, which has a property called position.

@interface Sprite : NSObject {
  CGPoint position;
}

@property (readwrite) CGPoint position;

@end

CGPoint is a struct with 2 int variables, x and y.

Lets create one:

Sprite mySprite* = [[Sprite alloc] init];

Now consider the situation of getting and setting the position.

Getting
When you call this:

CGPoint pos = mySprite.position;

It is actually the same as:

CGPoint pos = [mySprite position];

Here its clear that pos is a copy of the position (its not a reference
to the instance variable).

Setting
When you can call:

mySprite.position = pos;

It is actually the same as:

[mySprite setPosition:pos];

OK this is probably fairly clear so far!

The Gotcha
Now this is where the issue happens.

When you call this:

mySprite.position.y = 99;

It is actually the same as this:

[mySprite position].y = 99;

In this instance, the position variable of mySprite is not changed at all.

So when using properties, try to be aware of what Objective-C is actually doing behind the scenes :)