[英]How Can I Set Object from Dictionary to String Value to Update View Text Field?
如您在此處看到的,我有一個從CFDictionaryRef
的值:
CFDictionaryRef GPS = (CFDictionaryRef)CFDictionaryGetValue((__bridge CFDictionaryRef)(mutableMetadata), kCGImagePropertyGPSDictionary);
NSDictionary *gps_dict = (__bridge NSDictionary*)GPS;
NSLog(@"gps_dict: %@",gps_dict);
然后,我從字典值中提取latitudeValue
。 我已經在頭文件中聲明了latitudeValue
as和NSString
屬性,並對其進行了@implementation
合成:
latitudeValue = [gps_dict objectForKey:@"Latitude"];
在這一點上,我想獲取latitudeValue
的值,並讓它更新視圖上的文本字段。 該文本字段的標題為latValue
,並已作為IBOutlet
連接到頭文件中。 我嘗試了很多latValue.text = latitudeValue;
變體latValue.text = latitudeValue;
但是當我運行程序時,它們都會導致線程錯誤。 對我而言,建立聯系的最佳方式是什么? 謝謝你的時間。
[gps_dict objectForKey:@"Latitude"]
可能是數字對象(而不是string )。
因此,應將latitudeValue
聲明為NSNumber
屬性,然后:
latValue.text = [latitudeValue stringValue];
或更好
self.latValue.text = [self.latitudeValue stringValue];
使用屬性訪問器。 (請注意,您不必與當前的編譯器版本顯式地@synthesize屬性。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.