IOS description和debugDescription区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ws_752958369/article/details/82967747

相同点:

两者都可以格式化输出对象。

不同点:

description可以直接通过NSLog格式化输出,而debugDescription需要通过控制台命令输出po;

- (NSString *)description
{
    return [NSString stringWithFormat:@"<%@: %p,%@>",[self class],self,@{
        @{
           @"title":_title,
           @"latitude":_latitude,
           @"longitude":_longitude
         }
    }];
}

location:<EOCLocation:0x7f98f2e01d20>,{
    latitude = "51.506",
    longitude = 0,
    title = London
}

猜你喜欢

转载自blog.csdn.net/ws_752958369/article/details/82967747