plist檔案的內容的讀取

2021-07-16 19:12:44 字數 592 閱讀 7540

方法一:

nsstring *str =[[nsbundle mainbundle]pathforresource:@"flowers"oftype:@"plist"];

nsarray *arr = [nsarray arraywithcontentsoffole:str];//建立的資料型別是陣列array用此方法

nsdictionary *dic = [nsdictionary dictionarywithcontentsoffile:str];//建立的資料型別是字典dictionary用此方法

nslog測試

方法二:可變陣列可以用此方法

建立好可變的資料或字典:nsmutablearray和nsmtatabledictionary

nsstring *first = [[nsbundle mainbundle]pathforauxiliaryexecutable:@"first.plist"];

fisttmutablearray =[[nsmutablearray array]initwithcontentsoffile:first];

nslog測試

plist檔案,可以獲得兩種資料型別來儲存資料

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

provincesarray nsmutablearray alloc initwithcontentsoffile nsbundle mainbundle pathforresource provincesandcities.plist oftype nil plist的寫入是,你把你放在工程中的...

IOS讀取plist定義的內容

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

Mac OS,讀取plist檔案的方法

獲取plist檔案的路徑 nsstring plistpath nsbundle mainbundle pathforresource 檔名 oftype plist 讀取到乙個nsdictionary nsdictionary dictionary nsdictionary alloc initw...