plist檔案的讀取和xib載入cell

2022-07-15 02:51:11 字數 814 閱讀 3679

例如在工程裡倒入了plist檔案

在工程裡需要用到plist檔案裡的資訊,就需要把plist檔案讀取出來。

如程式:

-(nsarray *)moredataarr

return _moredataarr;

}

讀取plist檔案分兩步走:

載入xib分三步走:

註冊cell:

[self.tableview registernib:[uinib nibwithnibname:@"guesslovecell" bundle:nil] forcellreuseidentifier:@"guesslovecell"];
呼叫tableview**方法

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath
在guesslovecell類裡呼叫model的setter方法來賦值

-(void)setmodel:(guesslovemodel *)model{

_model = model;

//相關值

讀取和寫入plist檔案

plist檔案是標準的xml檔案,在cocoa中可以很簡單地使用。這裡介紹一下使用方法 以下 在mac和iphone中均適用。寫入plist檔案 nsmutabledictionary dict nsmutabledictionary alloc initwithcontentsoffile sam...

plist檔案的讀取和使用

nsbundle mainbundle pathforresource sysmessagering oftype plist plistpath 2 可以通過filemanager獲取該目錄下的所有檔案,來檢視獲取目錄是否正確 nsfilemanagerdefaultmanager content...

plist檔案的內容的讀取

方法一 nsstring str nsbundle mainbundle pathforresource flowers oftype plist nsarray arr nsarray arraywithcontentsoffole str 建立的資料型別是陣列array用此方法 nsdictio...