2010-07-16 52 views
0

如何打印 - > event.latitude = [[values objectAtIndex:0] floatValue]的值; ?如何打印對象變量?

下面是我的一些代碼:

@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]; 

如何打印出event.latitude?

我試過的NSString *str = [NSString stringWithFormat:@"%@", event.latitude];

謝謝你們。

+0

您應該添加Objective-C的標籤對這個問題。 – 2010-07-16 00:42:12

+1

@Jesse Dhillon - 你可以編輯他的標籤(因爲你的聲望超過500)。 – 2010-07-16 00:53:47

+0

謝謝你們,對於新手問題感到抱歉 – Morry 2010-07-16 01:32:26

回答

2

試試這個

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

注意格式字符串

1

如果你只是想打印出來,爲什麼不嘗試:

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