这是我在标题中的内容:
@interface myProject : UIVIEwController <CLLocationManagerDelegate> {double calculatedSpeed; UILabel *veLocityLabel;}
这里是我主要的:
-(voID)speedLocation:(CLLocationManager *)manager dIDUpdatetoLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{double gpsspeed = newLocation.speed;if(oldLocation != nil){ CLLocationdistance distanceChange = [newLocation getdistanceFrom:oldLocation]; NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp]; calculatedSpeed = distanceChange / sinceLastUpdate; veLocityLabel.text = calculatedSpeed;}}
注意我如何设置veLocityLabel到calculateSpeed,它是一个类型为double的变量.所以它自然会给我错误:“setText:”的参数1不兼容的类型.
你的帮助非常感谢
谢谢!
解决方法veLocityLabel.text = [Nsstring stringWithFormat:@"%g",calculatedSpeed];总结
以上是内存溢出为你收集整理的如何将类型转换为字符串iPhone?全部内容,希望文章能够帮你解决如何将类型转换为字符串iPhone?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)