fuz*_*oat 7 iphone cocoa-touch objective-c
我只是很好奇,有没有办法通过NSLog打印结构的内容?
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance([mp coordinate], 350, 350);
Run Code Online (Sandbox Code Playgroud)
我正在尝试输出什么[mp coordinate]进行调试.
.
我破解了它,除非有另一种方法.
CLLocationCoordinate2D location = [mp coordinate];
NSLog(@"LAT: %f LON: %f", location.latitude, location.longitude);
Run Code Online (Sandbox Code Playgroud)
Vla*_*mir 15
我知道没有通用的方法来记录结构值 - 如果你知道它的组件,你可以像你一样明确地记录它们CLLocationCoordinate2D.但是在您的类中,您可以实现-description和/或-descriptionWithLocale:方法并记录类实例:
NSLog([mp description]);
//or
NSLog(@"%@", mp);
Run Code Online (Sandbox Code Playgroud)
也有从一些标准结构创建NString方便的方法:NSStringFromCGAffineTransform,NSStringFromCGPoint,NSStringFromCGSize等
| 归档时间: |
|
| 查看次数: |
4744 次 |
| 最近记录: |