Objective-C
To program in iPhone OS, I need to understand the structure of Objective-C. I'll use this space to note things as I learn about them.
import
Use #import instead of #include, to avoid repetitive includes.
Classes
Classes can have parents, variables, methods, properties, and are instantiated in objects. The operating system (OS) makes space for those objects and their memory.
Objects
Objects are stored in a variable. An object can be typed to the class, or a pointer of type "id" that points to the object. A * in front of the variable name means a strongly-typed object declaration, where the object is a type of the class.
Methods
- Instance and Class methods
- A class in Objective-C can declare two types of methods: instance methods and class methods. An instance method is a method whose execution is scoped to a particular instance of the class. In other words, before you call an instance method, you must first create an instance of the class. Class methods, by comparison, do not require you to create an instance, but more on that later.
Protocols
Protocols declare methods that can be used by multiple classes (said to conform to such a protocol).
Protocols do not have a parent class and they don't define instance variables.
References
- Objective-C Primer at Apple
- http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/