home Objective-c basics   

Types:
id - object reference, like void for objects
Class
SEL
IMP - pointer to method implementation that returns id
BOOL: YES, NO
nil = (id)0 - null object ptr
Nil = (Class)0 - null class ptr

@interface <Name> : <Super Class> <Protocol List>
{
  id varOfTypeId;
  SEL varOfTypeSEL;
  IMP varOfTypeIMP;
  BOOL varOfTypeBOOL; // values: YES, NO
}
- methodWithNoArgs;
- (int)methodWithNoArgsReturnsInt
- (int)methodWithOneArg : (int)n;
- (void)initMeWith: (int) x and: (int) y and: (int) z;
+ classMethod; // aka. static method
@end

@implementation <Name>

@end

Each object has isa variable that points to class description. 
Class description points to super class.
Class has a map of selectors (SEL) to to methods.
SEL - compiler-assigned code that identifies a method.
Message send: call to a function that looks up method based on SEL and calls it.
Designed initializer - usually the most with most args. Should call super's designed initializer. Other initalizers should call designed initializer.

Categories - a way to add methods to a class defined in a different file.
Protocol - define a set of methods. Kind of like Interface in Java/C#

introspection method:
  isMemberOfClass:
  isKindOfClass:

← newer • 156 of 636older →