objective-c的description测试
来源:互联网 发布:教务网络管理系统入口 编辑:程序博客网 时间:2024/04/30 13:18
#import <Foundation/Foundation.h>@interface Human : NSObject { int age; NSString *name; Human *child;}@property int age;@property (copy)NSString *name;@property (retain)Human *child;@end@implementation Human@synthesize name;@synthesize age;@synthesize child;/*一般情况下,一个自定义类我们在用%@输出的时候,给出的是一个内存地址,我们在该类的.m文件里重写description方法,来修改输出内容*/#if 1-(NSString *)description { NSString *des = [NSString stringWithFormat:@"->%@,%d,%@",name,age,child]; return des;}#endif@endint main(int argc, const char * argv[]) { NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init]; Human *human1=[[Human alloc]init]; Human *human2=[[Human alloc]init]; human2.name=@"jeck"; human2.age=23; human1.child=human2; human1.name=@"holydancer"; human1.age=22; NSLog(@"%@",human1); [pool release]; return 0;}
结果:
2016-12-02 11:46:52.998 test[7289] ->holydancer,22,->jeck,23,(null)
0 0
- objective-c的description测试
- Objective-C的description方法
- Objective-C的description方法
- [Objective-C] 复写NSObject的description方法
- Objective-C - description 方法
- objective-C中的description方法
- objective-C中的description方法
- objective-c中类的本质与description
- objective-c的变量测试
- 浅谈objective-C中的description方法
- 浅谈objective-C中的description方法
- 黑马程序员----objective-C description NSLog SEL
- 黑马程序员---Objective-C Description方法
- 学习笔记(objective-c)-重写description方法
- objective-C语言_浅谈description方法
- 在自定义类中如何正确输出自定义类的属性值 objective-c的description
- objective-c---分类(category)、类的深入研究、NSLog、description方法
- Objective-C—构造方法、分类Category、类的深入研究、description方法、SEL
- No resource found that matches the given name 'Theme.Leanback'
- 一个老程序员告诉你:中国程序员为什么要跳槽
- linux运维命令
- shell实用命令
- 利用http模块进行post测试
- objective-c的description测试
- rabbit配置stomp为https
- Linux定时cron命令
- 手机访问PC站时自动跳转到手机站
- freeswitch修改mod_sofia
- iOS各种调试技巧豪华套餐
- Redis2.8从入门到精通文档
- QQ登录遇到的坑
- 符号三角形问题(dfs)