I'm trying to add an observer to my class so that it accepts notifications from GameKit on authorization changes.
Here is the code for adding the observer and the method it should be calling
override init(){
super.init()
NSNotificationCenter.defaultCenter().addObserver(self, selector: NSSelectorFromString("authenticationChanged:"), name: GKPlayerAuthenticationDidChangeNotificationName, object: nil)
}
func authenticationChanged(notification:NSNotification){
}
But it's giving me this error:
2014-11-18 13:11:19.262 Name[8074:1078111] *** -[Name authenticationChanged:]: message sent to deallocated instance 0x174423500
What am I doing wrong?
The object has been deallocated. You need to remove yourself as an observer in
deinit
: