OC反射机制

大部分的动态反射支持来自NSObject 类。NSObject是所有类(除了一些很少见的例外)的根类。所以所有你写的类应该都可以支持反射


NSObject 提供了一些简单的查询运行时系统信息的方法:

- (BOOL)isKindOfClass:(Class)aClass  判断是否是指定类或其子类的实例(检查继承关系)
Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.

- (BOOL)isMemberOfClass:(Class)aClass  判断是否是指定类的实例(精确类匹配)
Returns a Boolean value that indicates whether the receiver is an instance of a given class.

- (BOOL)respondsToSelector:(SEL)aSelector   是否实现或继承了指定方法
Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message.

- (BOOL)conformsToProtocol:(Protocol *)aProtocol  是否符合协议
Returns a Boolean value that indicates whether the receiver conforms to a given protocol.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值