Dynamically type objects by declaring them as id.
id myObject;
Since the class of dynamically typed objects is resolved at runtime, you can refer to them in your code without knowing beforehand what class they belong to. Type outlets and objects in this way if they are likely to be involved in polymorphism and dynamic binding.
Statically type objects as a pointer to a class.
NSString* mystring;
You statically type objects to obtain better compile-time type checking and to make code easier to understand.
Declarations of instance methods begin with a minus sign (-); a space after the minus sign is optional.
- (NSString*)countryName;
Put the type of value returned by a method in parentheses between the minus sign (or plus sign for class methods) and the beginning of the method name. Methods that return nothing must have a return type of void.
Method argument types are in parentheses and go between the argument’s keyword and the argument itself.
- (id)initWithName:(NSString*)name andType:(int)type;
Be sure to terminate all declarations with a semicolon.
By default, the scope of an instance variable is protected, making that variable directly accessible only to objects of the class that declares it or of a subclass of that class. To make an instance variable private (accessible only within the declaring class), insert the @private compiler directive before the declaration.
Last updated: 2007-10-31