Categories
Featured iPhone Development Resources

iPhone SDK Objective-C Cheat Sheet Updated

I have updated the Cheat Sheet on this site with larger headers as suggested by visitors to the site.  For those that don’t know this is a cheat sheet designed for beginners just getting started with the iPhone SDK who have some knowledge of C/C++ or Java providing comparisons with similar syntax in those languages for common Objective-C keywords.

Covered is:
Messages
Import
Self
Method Headers
Inheritance
Property and Synthesize
Interface
Implementation
Protocol
Id

 You can find the cheatsheet here:
>>> iPhone Objective-C Cheat Sheet <<<
 
This is the original video I made explaining the concepts contained within this cheatsheet:

Here is a little video I made about this cheatsheet update:

Please post any suggestions for improvement in the comments.
Thanks.

13 replies on “iPhone SDK Objective-C Cheat Sheet Updated”

The cheat sheet refers to “@property dataType variableName” and “@synthesize variableName”. That's incorrect; properties are not the same thing as instance variables. A property may use an instance variable for storage, but it isn't one itself. That's part of why people are confused by the difference between referring to just “foo” in their class and referring to “self.foo” – people tell them properties are a way of declaring accessors for instance variables, not that they're a way of declaring methods that may access an instance variable.

Chris.. I honestly don't see how you get that from the sheet, but maybe it's because I've never confused properties with instance variables. How would you state it?

one suggestion: how about something about using “+” instead of the leading “-” to indicate a static method… it's the kind of thing that's impossible to Google to find out, and I'm sure there are lots of people new to Objective C who are asking themselves “why does everything have a leading dash?”

A leading + doesn't indicate a static method, it indicates a class method. The difference is that class methods are dynamically dispatched just like instance methods, and can be overridden in subclasses just like instance methods.

That's exactly my point–I had no idea what it's called, so that would be a great thing for the cheat sheet because you can't Google “objective C plus minus” to find out what it means. I was saying that it's like a C++ static method in the sense that it doesn't operate on a specific instance of a class.

(Hey, you know what–I just assumed that that Google search wouldn't work. If you actually do the search, the first result is the Wikipedia Objective C page with an explanation of what + and – mean. Google, I will never doubt you again.)

Why aregue about these semantics?

The terms class method and static method are basically interchangeable, just check wikipedia, or check numerous books.

http://en.wikipedia.org/wiki/Method_(computer_s…)

Yes, class methods are dynamically dispatched, but they're just like C++ static methods as the poster said. It's just semantics that won't matter to someone who is brand new to the language and needing a cheat sheet.

Thanks for everyone's comments and am going to implement as much as I can into the cheat sheet..

Keep in mind, I originally created this cheat sheet for people just transitioning from C/C++/Java to Obj-C for the first time so that they could begin to understand the code.

My plan is to create another cheat sheet with more intermediate concepts specifically to coincide with the second app that we'll be creating in my video tutorials. Before a more advanced cheat sheet prior to getting into apps using OpenGL ES.

Stay tuned, and I appreciate all the suggestions so keep them coming.

Add categories?
ie:
@interface NSString (MyCoolAddition)
– (NSString *)shuffleString;
@end

@implementation NSString (MyCoolAddition)
– (NSString *)shuffleString {
//Do some shuffling here
//Return shuffled string
}
@end

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.