IOS讀取plist

plist其實是一個xml文件
首先我們需要讀取制定的文件
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@“myOlders” ofType:@“plist”];

然後我們就可以從中讀取相應的數據,這裏我們數據的最外邊是一個數組,這樣我們從指定的路徑中就可以獲取相應的數據。

NSArray *all Older s =[[NSArray alloc] initWithContentsOffile:plistPath];

關於數據字典,例如:
NSDictionary *tmpInfo = [dictionary objectForKey: @”Student”];
self.stuName.text = [NSString stringWithFormat:@”%@”, [tmpInfo objectForKey: @”Name”]];
self.stuSex.text = [NSString stringWithFormat:@”%@”, [tmpInfo objectForKey: @”Sex”]];
self.stuNum.text = [NSString stringWithFormat:@”%@”, [tmpInfo objectForKey: @”Num”]];
通過制定的名字找到對應的數據。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章