ios中讀取plist檔案內容的方法

2021-06-19 15:05:26 字數 725 閱讀 4151

_provincesarray = [[nsmutablearray alloc] initwithcontentsoffile:[[nsbundle mainbundle] pathforresource:@"provincesandcities.plist" oftype:nil]];

plist的寫入是,你把你放在工程中的plist刪掉。你要寫入plist的時候,

如果發現沒有該plist,其會幫新建該plist。

下面的plist裡面存放這的是array陣列

以下是顯示plist的**:

nsstring *path =[[nsbundle mainbundle] pathforresource:@"data" oftype:@"plist"];

nsmutablearray *array = [[nsmutablearray alloc] initwithcontentsoffile:path];

寫入plist的**:

nsstring *path1 = [[nsbundle mainbundle] pathforresource:@"data" oftype:@"plist"];

nsarray *array1 = [[nsarray alloc] initwithobjects:@"hello1",@"hello2",@"hello3",nil];

[array1 writetofile:path1 atomically:yes];

就這麼簡單。

IOS讀取plist定義的內容

已經在自動建立的info.plist檔案中新增了乙個字典元素,元素儲存的是乙個陣列 字典的key是mainitems nsstring file nsbundle mainbundle pathforresource info oftype plist nsmutabledictionary dic...

plist檔案的內容的讀取

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

Iphone開發中無法讀取plist檔案的問題

有的書籍上關於要讀取plist檔案的說明是 先要在xcode檔案中建乙個plist檔案,然後把根型別改為陣列,用下面的 即可 nsstring path nsbundle mainbundle pathforresource drinkarray oftype plist build the arr...