-2

When I write a new method signature in Swift, I follow the pattern:

func methodName(varName1: VarType1, varName2: VarType2, ...) {

Looking at some of the required protocol initializers, I have found a mystery third word in the signature. For example:

required init?(coder aDecoder: NSCoder) {

I understand that aDecoder is the param name and NSCoder is the type. But what on Earth is coder? For the love of all that's good, why does Swift have to make simple things so confusing?

Alex311
  • 378
  • 3
  • 12
  • because you don't read the documents? `coder` is label name, `aDecoder` is variable name, `NSCoder` is type name. all of these are properly documented in the official swift document. – Bryan Chen Sep 23 '15 at 22:46
  • I did read the docs and went through the tuts. It wasn't too clear that the variable name wasn't the label. – Alex311 Sep 23 '15 at 22:50

1 Answers1

-1

In this case coder is the parameter's external name and aDecoder is the parameter's local name.

Alex311
  • 378
  • 3
  • 12