Whenever Apple creates its own custom classes, it often creates a pointer to the object instead of the actual object itself.
For example, instead of doing:
Class object
They often do:
Class *object = [[Class alloc] init];
Why are pointers so commonly used instead of putting the object on the stack? Is there some technical reason for this, because I don’t see any immediate benefit of doing so.
EDIT: If Objective-C doesn’t support objects on the stack how can they create any non-pointers? I mean I have seen people use NSInteger directly.
Objective-C doesn’t support objects on the stack.
Fantastic explanation on Mike Ash’s blog here