OC-description方法重写

description方法的作用是打印对象
对于一个Person类,如果没有重写description方法,NSLog(@“%@”,p),输出的是对象的内存地址,而我们想要的效果是打印出Person的成员变量,所以我们可以在Person类里重写description方法。

description方法,返回值是OC字符串

- (NSString *)description
{
   return    [NSString stringWithFormat:@”name is%@”,_name];
}
原文地址:https://www.cnblogs.com/marshall-yin/p/4721253.html