在IOS中从plist获取字符串值

时间:2016-07-19 09:42:21

标签: ios objective-c plist

我一直在研究iOS中的plist。我已将字体样式 Marker Felt Thin 25.0 保存为plist中的字符串。

现在我想检索该字符串并将字体分配给我的tableview单元格文本。

虽然我在尝试不影响细胞为什么会这样......?

NSString *path = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"];

// Load the file content and read the data into arrays

NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];

cell.textLabel.font=[UIFont fontWithName:[[dict objectForKey:@"Font"]size:15]];

我怎么能这样做??

这是plist截图

PList [2423:126298] {     名字=(         阿吉特,         Bhuvan,         嘉莉         大卫,         Ezzel,         Farroq,         Quresema,         Ganesh神,         哈里斯,         我是男人,         贾格迪什,         凯文,         露西,         马诺,         弥敦道,         奥拉姆,         爬完,         雷米,         三,         TANU,         Urmilla,         维迪亚,         沃森,         哈维,         雅米妮(Yamini),         查希尔     );     font =" Marker Felt Thin&#34 ;; }词典值

2 个答案:

答案 0 :(得分:1)

字典键是font而不是Font。键区分大小写。

使用:

 cell.textLabel.font = [UIFont fontWithName:dict[@"font"] size:15];

答案 1 :(得分:0)

我认为您的问题在于

cell.textLabel.font = [UIFont fontWithName:[dict objectForKey:@"Font"] size:15]];

可能是这样的:

sql> select * from test;
| _TIME         | _CONVERTED_TIME
| 1468309423961 | null
| 1468309423962 | null
| 1468308812001 | null
| 1468308815972 | null
(4 rows, 10 ms)
sql> 
sql> 
sql> select DATEADD('SECOND', SUBSTRING(_time,1,10), DATE '1970-01-01') from test;
DATEADD('SECOND', SUBSTRING(EVENT_TIME, 1, 10), DATE '1970-01-01')
2016-07-12 07:43:43.0
2016-07-12 07:43:43.0
2016-07-12 07:33:32.0
2016-07-12 07:33:35.0