iOS在isKindOfClass和isMemberOfClass之间的区别 [英] iOS difference between isKindOfClass and isMemberOfClass

查看:206
本文介绍了iOS在isKindOfClass和isMemberOfClass之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

isKindOfClass:(Class)aClassisMemberOfClass:(Class)aClass函数之间有什么区别? 我知道这有点小,一个是全局的,另一个是完全匹配的类,但是我需要有人指定哪个是哪个.

What is the difference between the isKindOfClass:(Class)aClass and the isMemberOfClass:(Class)aClass functions? I know it is something small like, one is global while the other is an exact class match but I need someone to specify which is which please.

在Swift isKind(of aClass: AnyClass)isMember(of aClass: AnyClass)中.

推荐答案

isKindOfClass:返回YES从指定类继承的任何类的实例.

isKindOfClass: returns YES if the receiver is an instance of the specified class or an instance of any class that inherits from the specified class.

isMemberOfClass:仅在接收者是指定类的实例的情况下返回YES.

isMemberOfClass: returns YES if, and only if, the receiver is an instance of the specified class.

大多数时候您想使用isKindOfClass:来确保您的代码也可用于子类.

Most of the time you want to use isKindOfClass: to ensure that your code also works with subclasses.

NSObject协议参考详细讨论这些方法.

这篇关于iOS在isKindOfClass和isMemberOfClass之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆