
我尝试了几种不同的方法,但他们没有工作:
CLLocationCoordinate2D centerCoord;centerCoord.latitude = self.locModel.userLocation.coordinate.latitude ;centerCoord.longitude = self.locModel.userLocation.coordinate.longitude; Nsstring *tmpLat = [[Nsstring alloc] initWithFormat:@"%g",centerCoord.latitude];Nsstring *tmpLong = [[Nsstring alloc] initWithFormat:@"%g",centerCoord.longitude];NSLog("User's latitude is: %@",tmpLat);NSLog("User's longitude is: %@",tmpLong); 这会返回编译器的警告.
警告是
warning: passing argument 1 of 'NSLog' from incompatible pointer type
我该怎么做呢?
任何帮助,将不胜感激.
谢谢
解决方法 你没有提到警告是什么,但最有可能是因为你忘记了NSLog字符串前面的@:NSLog(@"User's latitude is: %f",self.locModel.userLocation.coordinate.latitude );NSLog(@"User's longitude is: %f",self.locModel.userLocation.coordinate.longitude );
您的更新代码应为:
NSLog(@"User's latitude is: %@",tmpLat);NSLog(@"User's longitude is: %@",tmpLong);
NSLog需要一个Nsstring参数,前面需要一个@符号.如果没有@符号,则字符串是普通的C字符串而不是Nsstring对象.
总结以上是内存溢出为你收集整理的cocoa – 将CLLocationCoordinate2D类型转换为数字或字符串全部内容,希望文章能够帮你解决cocoa – 将CLLocationCoordinate2D类型转换为数字或字符串所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)