isMemberOfClass vs comparing classes with ==

十年热恋 提交于 2019-12-07 17:49:06

问题


Is there any real difference between:

id value;
BOOL compare1 = [value isMemberOfClass:[SomeClass class]];
BOOL compare2 = [value class] == [SomeClass class];

to check if value is a SomeClass object?


回答1:


If value is an NSProxy, isMemberOfClass: will properly check the proxied object, the other construct, I believe, won't (I think it will clumsily duplicate isProxy:).



来源:https://stackoverflow.com/questions/3126476/ismemberofclass-vs-comparing-classes-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!