Swift plist檔案資料的讀取和儲存

2021-07-16 12:44:11 字數 2053 閱讀 2692

2015-09-28 09:37

發布:hangge

每次在xcode中新建乙個ios專案後,都會自己產生乙個.plist檔案,裡面記錄專案的一些配置資訊。我們也可以自己建立.plist檔案來進行資料的儲存和讀取。

.plist檔案其實就是乙個xml格式的檔案,其支援的資料型別有(ns省略)dictionary、array、boolean、data、date、number、string這些型別。

當然對於使用者自定義的物件,通過nscoder轉換後也是可以進行儲存的。(常見我的另一篇文章「

swift - 本地資料的儲存與載入(使用nscoder將物件儲存到.plist檔案)」)

本文主要介紹如何使用.plist檔案進行陣列,字典,字串等這些基本資料型別的儲存和讀取。

由於不需要轉化,所以用起來還是很方便的。而且在大多數情況下,使用基本資料型別就足夠了。

1,陣列(array)的儲存和讀取

(1)儲存

進入目錄開啟webs.plist,可以看到生成的資料如下:

檔案資料組織

資料庫的基本概念 二 曾士熊 原文 http www.ascc.sinica.edu.tw nl 83 1009 section3 3.html 劉建文整理 http blog.csdn.net keminlau 本文接第10個卷08期68頁 常見的電腦檔案包括 可執行程式檔案,批處理檔案,文字檔案...

python檔案資料操作

coding utf 8 import re import sys import struct import array import numpy as np define 8000 3 if name main sourcefilename r c users sophie desktop all...

解析txt檔案資料

publicclassfileaccessextendsactivitycatch exception e 讀檔案在.data data 包名 files 下面 param filename return publicstring readfiledata string filename catch...