Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated initWithCoder to correct implementation with proper initializ… #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apwelsh
Copy link

@apwelsh apwelsh commented Mar 22, 2017

…er method

The initWithCoder method is missing a call to [self init], so I modified the initWithCoder function to adhere to the standard initializer template.

…er method

The initWithCoder method is missing a call to [self init], so I modified the initWithCoder function to adhere to the standard initializer template.
@apwelsh
Copy link
Author

apwelsh commented Mar 22, 2017

I just saw the change log notation that the initWithCoder method no longer calls the init method. Ignore my pull request. But please explain why this was done?

@nicklockwood
Copy link
Owner

It's tricky. initWithCoder is not supposed to call [self init] because then you'd probably be setting all the properties twice.

Ideally it would call [super init] or [super initWithCoder:], but that's not possible here since it's implemented as a category on NSObject, which has no superclass.

@nicklockwood nicklockwood force-pushed the master branch 2 times, most recently from 577f9ba to e4b098a Compare October 26, 2017 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants