iOS检查继承关系
2016-02-29 09:22
435 查看
#import <Foundation/Foundation.h> @interface JYPerson : NSObject<NSCoding> @property(nonatomic,copy)NSString *name; @property(nonatomic,copy)NSString *age; @end
<pre name="code" class="objc">#import "ViewController.h" #import "JYPerson.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; JYPerson *person=[[JYPerson alloc]init]; //1.通过对象来判断该对象的class NSLog(@"通过对象来判断该对象的class:%@",[person class]); //2.判断对象是否为某个类的实例 NSLog(@"判断对象是否为某个类的实例:%d", [person isMemberOfClass:JYPerson.class]); NSLog(@"判断对象是否为某个类的实例:%d", [person isMemberOfClass:[NSObject class]]); //3.判断对象是否为某个类及其子类的实例 NSLog(@"判断对象是否为某个类及其子类的实例:%d",[person isKindOfClass:[NSObject class]]); NSLog(@"判断对象是否为某个类及其子类的实例:%d",[person isKindOfClass:[JYPerson class]]); //判断对象是否实现了指定协议 NSLog(@"判断对象是否实现了指定协议:%d",[person conformsToProtocol:@protocol(NSCoding)]); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- 总结iOS App开发中控制屏幕旋转的几种方式
- iOS崩溃调试
- 整理常用的iOS第三方资源
- iOS 关闭键盘 [self endEditing: YES]
- 让web应用正常显示ios输入法表情
- 如何让自己的web应用支持iOS表情
- [ios]iOS 图形编程总结
- iOS中Quartz2D图片裁剪和图片增加文字描述
- iOS MVC设计模式与MVVM设计模式简介 —— HERO博客
- [iOS] 绘图 CGContext 用法
- ios 照相机和相册的调用
- iOS -- NSURLSession 实现断点下载
- iOS-自定义图片大小
- ios卡牌游戏项目源码
- 蜂窝教育iOS培训:认真对待每位学员
- IOS tableview
- openstack 中 启动虚拟机出现MP-BIOS bug:8254 timer not connected to IO-APIC
- iOS开发(OC)中的命名规范
- 【iOS】自定义TabBarController
- IOS设计模式-组合设计模式