Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用dynamic修饰后,didSet仍然不执行 #389

Open
zhangjianjun056 opened this issue Jun 18, 2020 · 1 comment
Open

使用dynamic修饰后,didSet仍然不执行 #389

zhangjianjun056 opened this issue Jun 18, 2020 · 1 comment

Comments

@zhangjianjun056
Copy link

zhangjianjun056 commented Jun 18, 2020

使用的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 {
            
        }
    }
@zhangjianjun056
Copy link
Author

解决办法:在变量前面加上@objc就好了!!!
@objc var state:Int = 0 {
didSet {
switch state {
case 1:
typeTuple = ("开始",0xFF8833)
case 2:
typeTuple = ("处理",0xFF8833)
default:
typeTuple = ("",0xFF8833)
}
}

    willSet {
        
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant