1

Whats the role of NSCoder here?

- (id)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self)
    {

    }
    return self;
}
1
  • This has absolutely nothing to do with Xcode. Commented Feb 6, 2012 at 7:31

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.