本文介绍了如何保存快速阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Swift中创建一个基于优先级管理任务的应用程序。我目前将任务放入数组中。有没有人知道如何保存这个数组,这样当我打开应用程序时,我仍然可以访问数据?
I am creating an app in Swift that manages tasks based off of priority. I currently place the tasks into an array. Does anybody know how I can save this array so that when I open the app I will still be able to access the data?
推荐答案
使用NSUserDefaults。
Use NSUserDefaults.
保存数组:
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject(myArray, forKey: "myarray")
defaults.synchronize()
读取数组:
myArray = defaults.dataForKey("myarray") as Array
这篇关于如何保存快速阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!