退出+目标c后在数组中获取值 [英] getting values in an array after exiting+objective c
本文介绍了退出+目标c后在数组中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的iPhone应用程序中,我将值存储在一个数组中,并希望在重新加载该应用程序时检索它.也就是说,当用户退出我的应用程序时,我希望保存此数组,以便在加载应用程序时再次由用户想要访问.
In my iphone application I am storing values in an array and I want to retrieve it when I reload the application.That is,When the user exits my app, I want this array to be saved so that when the app is loaded again by the user it want to be accessed.
推荐答案
要补充先前的答案,您可以使用KeyedArchiver来将对象读/写到文件中.
To complement previous answers, you can use KeyedArchiver to read / write your object to file.
BOOL result = [NSKeyedArchiver archiveRootObject:your_NSArray toFile:filePath];
和
id archive = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
可通过以下方式访问应用程序可以在其中存储文件的标准iOS目录
Standard iOS directories where your application can store files are accessed through
NSSearchPathForDirectoriesInDomains
这篇关于退出+目标c后在数组中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文