Whats the role of NSCoder here?
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
}
return self;
}
Whats the role of NSCoder here?
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self)
{
}
return self;
}
NSCoder
holds the state you saved the archive representation of the instance to initialize in -[id<NSCoding> encodeWithCoder:]
.
In other words, you encoded an instance of self at one point in time, now you need the coder's info to restore your state.
NSCoder handles archiving, most particularly in this typical case of a view, the archiving of a NIB. So when you initWithCoder
the NIB is loaded, with the interface you've constructed in Interface Builder.
You can read more here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Protocols/NSNibAwaking_Protocol/Reference/Reference.html