问题
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