问题
I recently updated my Xcode from Xcode 7 beta 4 to Xcode 7 beta 5 and began to have an error that wasn't present before. That being: "AllocWithZone is unavailable in Swift: use Object Initializers instead."
Here is the code where the error is found:
public func copyWithZone(zone: NSZone) -> AnyObject {
let copy = self.dynamicType.allocWithZone(zone) as ChartDataSet
copy.colors = colors
copy.label = self.label
return copy
}
What do I substitute in place of ".allocWithZone" so that it utilizes an Object Initializer instead of this Obj C component?
回答1:
I used this, and the iOS Charts library works for me:
let copy=self.dynamicType.initialize() as! ChartDataEntry
来源:https://stackoverflow.com/questions/31885231/using-object-initializers-in-swift-to-replace-allocwithzone