使用的HandyJson版本是5.0.2,变量使用dynamic修饰后,didSet仍然不执行。
dynamic var state:Int = 0 {
didSet {
switch state {
case 1:
typeTuple = ("开始",0xFF8833)
case 2:
typeTuple = ("处理",0xFF8833)
default:
typeTuple = ("",0xFF8833)
}
}
willSet {
}
}
1条答案
按热度按时间k10s72fa1#
解决办法:在变量前面加上@objc就好了!!!
@objc var state:Int = 0 {
didSet {
switch state {
case 1:
typeTuple = ("开始",0xFF8833)
case 2:
typeTuple = ("处理",0xFF8833)
default:
typeTuple = ("",0xFF8833)
}
}