- Manuel Berger
- Cocoa Programming for Mac OS X
- July 14, 2010
- Thomas Mertz
- Cocoa Programming for Mac OS X
- March 11, 2010
- Jonas Wisser
- Cocoa Programming for Mac OS X
- January 11, 2010
This chapter took longer to read than I expected. Mainly because it had so much information stuffed into it.
When using NSAssert( ), you have to distinguish between a debug and release builds because in a release build you don't want assertions checked.
To do this double click the target to bring up build info. Under build tab and 'release' selected under Configuration, add NS_BLOCK_ASSERTIONS as a value to Preprocessor Macros under GCC Preprocessing.
Use the code on this page when you want to throw an exception when an initialization is called w/o arguments.
"Following are rules that Cocoa programmers try to follow regarding initializers:
*You do not have to create any initializer in your class if the superclass's initializers are sufficient.
*If you decide to create an initializer, you must override the superclass's designated initializer.
*If you create multiple initializers, only one does the workâthe designated initializer. All other initializers call the designated initializer.
*The designated initializer of your class will call the superclass's designated initializer."
About messaging in Obj-C:
*Every Obj-C object has an isa pointer to the class structure that created it. This structure contains information about the variables and implementation of methods.
*Each method in an index is associated with a selector, which is a number that is associated with a method (making selectors and methods a one-to-one relation).
*What the compiler does when it encounters a message send is that it interprets it as an objc_msgSend() function with the arguments being whatever that was in the brackets [ ] and replacing the method name with the corresponding selector number. It looks for this number in the class and if not, the super-classes.
*This dynamic structure allows programs to have classes and methods added to it while it is running.
Additional information
- Pages: 464
- ISBN: 0321503619
- Dewey: 005.268
- Binding: Paperback
- Publisher: Addison-Wesley Professional
- Amazon
- BookMooch
- Google books