0

I recently began using Parse.com with swift and I am trying to create a simple app loading data into a table. In using the class PFQueryTableViewController, I found that the following code must be used:

override init!(style: UITableViewStyle, className: String!) {
    super.init(style: style, className: className)
}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    self.parseClassName = "MyClass"
    self.pullToRefreshEnabled = true
    self.paginationEnabled = true
    self.objectsPerPage = 50
}

My question is why must initialization of this class be called twice? and what are these initializations accomplishing?

Code was taken from this question: PFQueryTableViewController in Swift using Cloud Code function

1 Answer 1

1

The initialization is not called twice; by defining two initializers you define two different ways to initialize an object. It's like with NSNumber:

  • init(float: Float)
  • init(double: Double)
  • init(bool: Bool)
  • and 13 more...

You use only one of them when initializing your NSNumber instance.


The requirement of init?(coder: NSCoder) is a different topic, discussed in the following questions:

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.