“initialize” class method for classes in Swift?

后端 未结 6 1095
日久生厌
日久生厌 2020-12-04 11:55

I\'m looking for behavior similar to Objective-C\'s +(void)initialize class method, in that the method is called once when the class is initialized, and never a

6条回答
  •  悲哀的现实
    2020-12-04 12:21

    For @objc classes, class func initialize() definitely works, since +initialize is implemented by the Objective-C runtime. But for "native" Swift classes, you'll have to see the other answers.

提交回复
热议问题