2013-11-23 11 views
0

我有我從CFDictionaryRef拉着一個值,你在這裏看到:如何將字典中的對象設置爲字符串值以更新查看文本字段?

CFDictionaryRef GPS = (CFDictionaryRef)CFDictionaryGetValue((__bridge CFDictionaryRef)(mutableMetadata), kCGImagePropertyGPSDictionary); 
    NSDictionary *gps_dict = (__bridge NSDictionary*)GPS; 
    NSLog(@"gps_dict: %@",gps_dict); 

然後我從字典中值拉latitudeValue。我宣佈latitudeValue爲,並在頭文件NSString財產和合成它@implementation

latitudeValue = [gps_dict objectForKey:@"Latitude"]; 

在這一點上,我想取值latitudeValue並將其更新視圖中的文本字段。該文本字段標題爲latValue,並在頭文件中作爲IBOutlet連接。我已經嘗試了不少latValue.text = latitudeValue;的變體,但是當我運行該程序時,它們都會導致線程錯誤。什麼是我建立這種聯繫的最佳方式?謝謝你的時間。

回答

0

[gps_dict objectForKey:@"Latitude"]可能是一個對象(而不是)。

因此,你應該申報latitudeValueNSNumber屬性,然後:

latValue.text = [latitudeValue stringValue]; 

或更好

self.latValue.text = [self.latitudeValue stringValue]; 

使用屬性訪問器。 (請注意,您不必在當前編譯器版本中明確指定@synthesize屬性 。)

+0

謝謝您的及時答覆!它現在肯定有效。我不知道爲什麼,但Xcode讓我改變它''self> latValue.text = [self.latitudeValue stringValue];'我將不得不研究'.'語法與' - >'' – Presto

相關問題