讀寫 plist檔案的例子

2021-06-07 04:17:40 字數 524 閱讀 9628

想在乙個類裡把個陣列寫進.plist檔案裡,再在另乙個類裡從這個.plist檔案把陣列讀取出來?

以name,phonenumber,age三個字段,為例。我是做的iphone,在文字框中輸入資料,獲取後,裝入陣列中。然後把陣列寫入.plist檔案

寫操作nsstring *name=[txt1 text];

nsnumber *phonenumber=[[nsnumber alloc] initwithint:[[txt2 text] intvalue]];

nsnumber *age=[[nsnumber alloc] initwithint:[[txt3 text] intvalue]];

nsmutablearray *array=[[nsmutablearray alloc]init];

[array  addobject:name];

[array  addobject:phonenumber];

[array  addobject:age];

讀操作[array release];

plist檔案的讀寫

在做ios開發時,經常用到到plist檔案,那plist檔案是什麼呢?它全名是 property list,屬性列表檔案,它是一種用來儲存序列化後的物件的檔案。屬性列表檔案的擴充套件名為 plist 因此通常被稱為 plist檔案。檔案是xml格式的。plist檔案通常用於儲存使用者設定,也可以用於...

plist屬性列表 檔案的讀寫

plist 是資料持久化的一種 是屬性列表 把陣列寫入到檔案中 1 檔案路徑 2 把資料寫入檔案 1 檔案路徑 準備寫入的資料 先找到document檔案路徑 nsarray paths nssearchpathfordirectoriesindomains nsdocumentdirectory,...

IOS學習之 plist檔案的讀寫

在做ios開發時,經常用到到plist檔案,那plist檔案是什麼呢?它全名是 property list,屬性列表檔案,它是一種用來儲存序列化後的物件的檔案。屬性列表檔案的擴充套件名為 plist 因此通常被稱為 plist檔案。檔案是xml格式的。plist檔案通常用於儲存使用者設定,也可以用於...