Mobile Development

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/

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 :)

Deactivate iTunes account on iPhone

Was having trouble figuring out how to deactivate the itunes account on the iPhone.

I finally figured it out though:

1. Plug in your iPhone into your computer.
2. Open up iTunes.
3. Sign out of iTunes account on your computer (on Mac, this is under the Store menu).

Over the Air - iPhone Browser Apps, Native Apps / SDK

This session was with Brian Fling (Fling Media). Unfortunately there was also supposed to be someone there talking a little more in-depth about the SDK, but I still found the session really useful.

Some things I took out of the session was a really good overview of the 2 types of apps for an iPhone. Essentially there is a Web App and a Native App.
The Web App is essentially a web 2.0 website (and should then work in all web 2.0 browsers - although the list of theses is currently very small). When people talk about a Web App, the platform they are really talking about is WebKit (which is also the browser of choice for Nokia N95s).
The Native App is written in Objective-C, and gives the developer access to lower level features like Phone Book etc. From my perspective, unless you need to use the lower level access of a Native App, a Web App is the best way togo. There is also the fact that a Native App is distributed over the IPhone store, which is a closed Deck (just like those of the Network Operators). This for me, is another minus point against writing a Native App.

Brian’s a really great speaker, and I got alot out of the short session we had (which was also cut short by the Fire Alarm!). If you have the chance to meet him, I highly recommend you do so. It will be well worth your time.