#import "ViewController.h"
#import "friend.h"
#import "friendViewController.h"
#import "model.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
friend *fri;
model *models;
UITableView *_table;
NSMutableArray *arraymodel;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//
NSString *path = [[NSBundle mainBundle]pathForResource:@"friends.plist" ofType:nil];
NSArray *array = [[NSArray alloc]initWithContentsOfFile:path];
arraymodel = [NSMutableArray array];
for (NSDictionary *dics in array) {
//初始化模型
models = [[model alloc]init];
models.friends = dics[@"friends"];
models.name = dics[@"name"];
models.online = dics[@"online"];
//將模型的對象添加到數(shù)組
[arraymodel addObject:models];
}
//初始化表格
_table = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
_table.delegate = self;
_table.dataSource = self;
[self.view addSubview:_table];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return arraymodel.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellId = @"cellID";
UITableViewCell *cell
= [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
}
model *mo = [[model alloc]init];
mo = arraymodel[indexPath.row];
cell.textLabel.text = mo.name;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",mo.online];
return cell;
}
@end
iOS-Plist
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來恭应,“玉大人抄邀,你說我怎么就攤上這事≈玳唬” “怎么了境肾?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長胆屿。 經(jīng)常有香客問我奥喻,道長,這世上最難降的妖魔是什么非迹? 我笑而不...
- 正文 為了忘掉前任衫嵌,我火速辦了婚禮,結(jié)果婚禮上彻秆,老公的妹妹穿的比我還像新娘楔绞。我一直安慰自己,他們只是感情好唇兑,可當我...
- 文/花漫 我一把揭開白布酒朵。 她就那樣靜靜地躺著,像睡著了一般扎附。 火紅的嫁衣襯著肌膚如雪蔫耽。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼钦讳,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了枕面?” 一聲冷哼從身側(cè)響起愿卒,我...
- 正文 年R本政府宣布高诺,位于F島的核電站碌识,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏虱而。R本人自食惡果不足惜筏餐,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望牡拇。 院中可真熱鬧魁瞪,春花似錦、人聲如沸惠呼。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽剔蹋。三九已至旅薄,卻和暖如春诫钓,著一層夾襖步出監(jiān)牢的瞬間供炼,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 一 而叼! 在工程里直接創(chuàng)建一個Plist 文件: //獲取Plist 文件路徑 NSString *plistPat...
- 由于實驗室項目的需要將數(shù)據(jù)存入plist身笤,遇到了無法將數(shù)據(jù)寫入plist的情況,現(xiàn)在將遇到的兩種問題以及解決方法葵陵。...
- pip及setup.py安裝均報錯刪除Python/Lib下的fcntl.py及fcntl.pyc從以下鏈接重新下...