0

I'm having a problem with some code that I copied almost directly from the Parse docs. I think it is because something in the newer versions of Swift broke the code. The docs say that you can override initialize() in NSObject, but when I do that the program just hangs when I try to execute PFUser.loginWithUsernameInBackground().

The code that I've written is attached. Even if I don't instantiate a Movie, it crashes once the initialize() code is uncommented.

I really could use some help, as I've relied on this code (without, I confess, a 100% understanding of its significance).

class Movie:PFObject, PFSubclassing {

@NSManaged var title:String
@NSManaged var year:Int
 //   @NSManaged var producer:Producer

//    override class func initialize() {
//        struct Static {
//            static var onceToken : dispatch_once_t = 0;
//        }
//        dispatch_once(&Static.onceToken) {
//            self.registerSubclass()
//        }
//    }
//    
    static func parseClassName() -> String {
        return "Movie"
    }


}
rici
  • 234,347
  • 28
  • 237
  • 341
Michael Rogers
  • 1,318
  • 9
  • 22
  • What is the crash? – Paulw11 Oct 18 '16 at 23:52
  • There is no error in the Xcode console: all that happens is the button stays highlighted, and the program crashes. In the iOS simulator console, I do see one message ... Oct 18 19:35:13 Michaels-Mac-Pro assertiond[8751]: assertion failed: 16B2548a 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 and that's about it. – Michael Rogers Oct 19 '16 at 00:35
  • You should get an exception message. Are you sure it isn't just hitting a breakpoint (blue flag in the margin) ? – Paulw11 Oct 19 '16 at 00:37
  • That's a good question, but no, I definitely am *not* hitting any breakpoints. The program just stops, and the message that I was seeing in the console was what I wrote in my previous comment. Of course, now I can't even open the console, as it is crashing. – Michael Rogers Oct 19 '16 at 01:39
  • 1
    It appears that overriding initialize() may be problematic - there was another report about this on stack overflow.com. I deleted the function, and use Movie.registerSubclass() in the AppDelegate, and that seems to have resolved the issue. – Michael Rogers Oct 19 '16 at 13:08

0 Answers0