Objective-C description的用法
2015-10-25 22:54
351 查看
description类似于.net/java ToString()方法的用途。
假设有一个CTPerson类,
假设有一个CTPerson类,
- (NSString *)description { return @"description 来自对象描述"; } + (NSString *) description { return @"description 来自类描述"; }
CTPerson *person = [[CTPerson alloc] init]; NSLog(@"%@",person); //输出"description 来自对象描述" NSLog(@"%@",[CTPerson class]); //输出"description 来自类描述"
相关文章推荐
- Objective-C 成员变量的访问修饰即成员变量可见性解析
- Foundation 之 NSDictionary和NSMutableDictionary
- 使用Buildozer部署时,出现AttributeError: 'NoneType' object has no attribute 'group'错误的解决
- Objective-C代码块Block详解
- Foundation 之 NSArray和NSMutableArray
- error C2248: “CObject::operator =”: 不可访问 private 员(于“CObject”类声明)
- Object C学习笔记2-NSLog 格式化输出数据
- Object方法和异常总结(4)
- Python标准库:内置函数hasattr(object, name)
- js引用类型之Object类型
- Exception starting filter struts2 java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
- objective-c开发编码规范
- 学习ECMAScript5规范中Object新增的API
- javascript基本语法3 引用类型----Object
- QMetaObject::connectSlotsByName 总结
- Objective-C新特性
- 运行错误:error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or
- C# JArray与JObject 的使用 json [{}]
- Socket通信readObject()方法出现异常
- JavaScript Object类型 小抄