Method load() defines Objective-C class method 'load', which is not permitted by Swift 1.2

前端 未结 5 1585
一个人的身影
一个人的身影 2020-12-03 02:56

I\'m using Parse and I\'m creating a PFObject subclass conforming to the protocol PFSubclassing! It was working all fine, but now I\'m using Swift 1.2 and it gives me this

5条回答
  •  鱼传尺愫
    2020-12-03 03:36

    Overriding load() never worked with Swift. Earier it was simply not called. I filed a bug for Apple back then (Bug ID 18423731), and recently I got a response that the issue has been addressed by explicitly informing the developer that this is not allowed in Swift.

    extension UIButton {
        // !! never called
        override public class func load() { // Method 'load()' defines Objective-C class method 'load', which is not permitted by Swift 1.2
            super.load()
            println("not called earlier anyway");
        }
    }
    

    So.... don't. Even if the documentation says otherwise.

提交回复
热议问题