1

Recently I've updated from Xcode 6.2 to Xcode 6.3 beta 4 and opened my project. I had the following error on init(): Missing argument for parameter 'coder' in call. Heres my init() method:

public init(image: UIImage?) {
    super.init()
    commonInit(image)
}

Any solutions?

1 Answer 1

2

Swift initializer processing is tricky and very particular. You should really read about Swift Initializers in the language documentation to understand what you're doing.

You can have more than one init method, but you have to obey the inheritance and hierarchy rules. And you need to definitely understand what are called convenience initializers.

Having said that, many classes require at least one init overload like this:

init(coder aDecoder: NSCoder!)
{
    super.init(coder: aDecoder)
}

The compiler may be complaining because it thinks that's what you're trying to create but did it wrong.

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

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.