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

关于Associated Objects的疑问 #12

Closed
yeziahehe opened this issue Jan 6, 2016 · 6 comments
Closed

关于Associated Objects的疑问 #12

yeziahehe opened this issue Jan 6, 2016 · 6 comments
Labels

Comments

@yeziahehe
Copy link

在封装UIBarButtonItem的Category的时候,发现你使用了Associated Objects去进行了封装,因为你使用的时候必要时用一个block的property,我想问,下面的方式都能够实现同样的功能,Associated Objects的优点在哪儿?
2016-01-06 9 58 41

@ibireme
Copy link
Owner

ibireme commented Jan 6, 2016

没什么优势。。功能也不会有什么差异。
这块儿直接从 UIControl+YYAdd 里拷过来的代码,所以相关逻辑也带过来了。

@yeziahehe
Copy link
Author

@ibireme 我想了很久,一直徘徊这里,其实只是两种实现方式。因为Associated Objects优势体现在要自定义属性的时候。
我的另外一个问题,再有自定义属性的时候,什么情况下选用继承,什么情况下选用Associated Objects去做Category呢?

@ibireme
Copy link
Owner

ibireme commented Jan 6, 2016

没必要的话就不要用 Associated Objects,写起来麻烦,性能又不高。

@yeziahehe
Copy link
Author

性能不高指的是?是否有文档解释这个性能?

@ibireme
Copy link
Owner

ibireme commented Jan 6, 2016

没文档,但可以自己测一下。

@yeziahehe
Copy link
Author

好的,感谢!

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

No branches or pull requests

2 participants