0

我正在寻找离我当前位置最近的位置,我想要NSLog最接近的CLLocation变量名而不是它的值。

我该怎么做呢?这就是我获取变量经度和纬度值的方式:

NSLog(@"the closest location is %@", closestLocation);

例如,我希望它说:“最近的位置是星巴克(变量名)”而不是“最近的位置是 LONGITUDE,LATITUDE”。

4

1 回答 1

1

评论是正确的,但是由于您看不到连接,因此我将尝试说清楚:

#define LogTheLocationVariable(x) NSLog(@"The variable is %s", #x)

现在您可以使用宏:

LogTheLocationVariable(closestLocation);

你会得到:

The variable is closestLocation
于 2013-07-29T01:56:48.320 回答