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

用 Swift 实现轻量的属性监听系统 - 循环引用 #16

Open
zyg-github opened this issue Jan 27, 2016 · 0 comments
Open

用 Swift 实现轻量的属性监听系统 - 循环引用 #16

zyg-github opened this issue Jan 27, 2016 · 0 comments

Comments

@zyg-github
Copy link

hello 看了https://github.com/nixzhu/dev-blog/blob/master/2015-04-30-property-listener.md 发现 vc 没有被释放
加上个了 引用列表 如下
UserInfo.name.bindAndFireListener("ThirdViewController.nameButton") { [weak self = self] name in
if let viewController = self {
viewController.nameButton.setTitle(name, forState: .Normal)
}
}

    UserInfo.hairColor.bindAndFireListener("ThirdViewController.backgroundColor") { [weak self = self] color in
        if let viewController  = self {
            viewController.view.backgroundColor = color
        }
    }

不过 我感觉还需要完善 比如当 ViewController 销毁了 应该把事件移出
感觉 还是 NSNotificationCenter 方便 哈哈~

@zyg-github zyg-github changed the title 循环引用 用 Swift 实现轻量的属性监听系统 - 循环引用 Jan 27, 2016
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