isMemberOfClass vs comparing classes with ==

2019-05-10 00:35发布

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条回答
戒情不戒烟
2楼-- · 2019-05-10 01:13

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:).

查看更多
登录 后发表回答