2

Question regarding Swift and PFSubclassing. I have a class called WeatherNotification which is a subclass of PFObject. My class contains an init method that lets me set values when creating the object.

init(temp: Int) {
    self.temp = temp
}

However the compiler complains that I don't have super.init in there before I try and initialize a variable.

When I put super.init() in there above the self.temp line then I get a complaint at runtime.

weatherNotification.swift: 39: 7: fatal error: use of unimplemented 
initializer 'init()' for class 'perfectweather.WeatherNotification

Is there a different object initializer approach i need to use here? Do I need to switch to initializing via the properties?

Xcode 6.3.2 is being used. Parse API 1.7.5 is the parse api version

EDIT: I ended up switching from an init method to a setValues method which would take in the values I wanted to set on the object. That got me away from the init issues. However, I would like to understand what happened better so I'm leaving the question open!

Shaun
  • 4,057
  • 7
  • 38
  • 48
  • 1
    I have no experience with parse.com, but this looks closely related: [Subclassing PFObject in Swift](http://stackoverflow.com/questions/24581981/subclassing-pfobject-in-swift). – Martin R Jul 01 '15 at 17:15
  • @martinR that references a slightly tangential bug in an earlier version of parse. – Shaun Jul 01 '15 at 18:01
  • 1
    Just a note: Swift requires the super init to be called last. So `super.init()` should be called after the `self.temp = temp` line – kRiZ Jul 02 '15 at 02:23
  • @KRiz I think that is the answer! – Shaun Jul 03 '15 at 15:21

0 Answers0