Your iPhone Development Questions Answered
by Parveen Kaler
I’ve been getting a number of questions from programmers about iPhone development. I thought I would compile the answers into one place and push them out into the world.
The iPhone SDK has been updated at a blistering pace and the documentation has not kept up with the API changes as quick as it could be. Some of the information from Apple is inconsistent or incomplete.
Why do you have to create a Cocoa Touch application?
It’s not really possible to have command-line applications on the iPhone. So, you need to have some sort of view that can talk to the window manager on the iPhone.
What’s a XIB file?
XIB stands for XCode Interface Builder. It is the filetype that is spit out by the Interface Builder application.
http://developer.apple.com/tools/interfacebuilder.html
NIB stands for NextStep Interface Builder. It is the legacy filetype and name. Back in the day, when Steve was banished from Apple, he started a company called NeXT. It was eventually purchased by Apple. But a ton of work on Mac OS X, Cocoa, Objective-C came from NeXT.
http://en.wikipedia.org/wiki/NeXT
What’s up with all of this Objective-C stuff?
The best cheat sheet I’ve seen for Objective-C is here:
http://developer.apple.com/iphone/gettingstarted/docs/objectivecprimer.action
You need to be logged in as a registered Apple Developer to access that page.
The general rule is that if you see an @ sign, it is a directive to the compiler. If you see lines of code wrapped in square brackets, [...], then it is a message to a Objective-C object.
What’s a framework?
A framework is kind of like a class library in the Java sense. Here is the Framework Programming Guide:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html
Whenever you have a question about a high-level concept, you can search for the accompanying guide here:
http://developer.apple.com/documentation/DeveloperTools/Xcode-date.html
Why do class names start with ‘NS’?
NS stands for NeXTSTEP. Objective-C doesn’t have namespaces, so classes in frameworks get prefixes.
Newer frameworks get CF for Core Framework, CA for Core Audio, CM for Core Media, etc.
Comments
Hey Parveen!
Congrats on the new venture man – good stuff!
Have you done any metrics yet on rendering performance using OpenGL ES on the iPhone Hardware? I am wondering about things like polygon/texture budget needed to maintain 30Hz.
Also in the docs, it says that no more than 24MB of RAM should be allocated to texture and geometry. Do you know how much RAM is left for executable code at that point?
Likewise for sound – if you’re using 24MB for visuals, how much RAM is left for sound data and OpenAL?
Reading the Apple docs, I haven’t really seen these metrics laid out yet. Apologies if I’ve missed the obvious.
T
The answer is that it depends. The platform is much more virtualized and abstracted than the Sony PSP.
I haven’t really pushed the device to its limits yet. But the best set of numbers I’ve seen are here:
http://glbenchmark.com/phonedetails.jsp?D=Apple%20iPhone
The general guideline is that the iPhone is going to be fill limited. For example, two full screen textured quads would probably drop framerate by a ton.
Memory management is also a sticky point. It’s the one thing that developers get caught on. Objective-C supports memory pools much in the way we allocated memory on the PSP.
You probably want per-game, per-frame, and per-event memory pools. (Objective-C with Cocoa is event driven)
I haven’t been able to get solid numbers on resources. The iPhone is much like a PC in this respect. And iPhone OS 2.1 actually improved memory management by a ton. So all those numbers would have to be recalculated.
The next time I run the Shark Profiler, I’ll dig up some numbers and post them.