November 2013
Beginner
325 pages
9h 47m
English
Every once in a while, however, you cannot safely override the superclass’s designated initializer. Let’s say that you are creating a subclass of NSObject called BNRWallSafe, and its designated initializer is initWithSecretCode:. However, having a default value for secretCode is not secure enough for your application. This means that the pattern we have been using – overriding init to call the new class’s designated initializer with default values – is not acceptable.
So what do you do? An instance of BNRWallSafe will still respond to an init message. Someone could easily do this:
BNRWallSafe *ws = [[BNRWallSafe alloc] init];
The best thing to do is to override the superclass’s designated initializer in a way that ...
Read now
Unlock full access