开发者

How to print object variable?

开发者 https://www.devze.com 2023-01-08 01:42 出处:网络
How do I print the value of -> event.latitude = [[values objectAtIndex:0] floatValue];? Below is some of my code:

How do I print the value of -> event.latitude = [[values objectAtIndex:0] floatValue]; ?

Below is some of my code:

@interface SeismicEvent : NSObject <MKAnnotation>{
  float latitude;
  float longitude;


**This is an object
 SeismicEvent *event;


** This reads in a float

 event.latitude = [[values objectAtIndex:0] floatValue];

How do I print out event.latitude?

I tried NSString *str = [NSString stringWithFormat:@"%@", event开发者_如何学JAVA.latitude];

Thanks guys.


Try this

NSString *str = [NSString stringWithFormat:@"%f", event.latitude];

Notice the format string


If you're just trying to print it out, why not try:

NSLog(@"%f", event.latitude);
0

精彩评论

暂无评论...
验证码 换一张
取 消