I have a custom subclass of UIButton:
import UIKit
@IBDesignable
class MyButton: UIButton {
var array : [String]?
}
It is IBDesignable and I have set it as the custom class for one of the buttons in my storyboard. I would like to make it generic so that the array does not have to be one of String objects. So, I tried this:
import UIKit
@IBDesignable
class MyButton<T>: UIButton {
var array : [T]?
}
However, I am unsure how to set this as the class now in IB. I tried putting MyButton<String>
or MyButton<Int>
, but Interface Builder just removes the angle brackets portion and gets the following compile error:
Command /Applications/Xcode6-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
Is there a way to use a generic custom class, or is it not supported?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…