将NSMutable阵列存储到sqlite数据库中 [英] Store NSMutable Array into sqlite database

查看:62
本文介绍了将NSMutable阵列存储到sqlite数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i正在编写一个iPhone应用程序,需要一点帮助。.
i有这个uitableview,它显示nsmutable数组中包含的数据。.该数据是通过某些操作检索的,因此需要每次的数据都不相同...

hi i am writng an iphone app and need a bit of help.. i have this uitableview which displays data that is contained in a nsmutable array.. this data is retrieved via some operations therefore amount of data is not the same every time...

我想知道的是我是否有类似的东西:

what i want to know is if i had something like:

NSMutableArray * mArray;

NSMutableArray *mArray;

我将如何从sqlite数据库中存储和加载'mArray'。

how would i go about storing and loading the 'mArray' from an sqlite database..

按要求提供的其他信息:

Further info as requested:

@Caleb

@westsider

@westsider

数组内容:
数组的内容是简单的模块名称(即,学生在课程中学习的主题),可从.ics中检索日历文件,其中包含一些解析操作。.我最终得到一个包含所需数据的数组,然后使用表格视图显示该数据。

Array Contents: The contents of the array are simple module names (i.e subjects that a student learns on a course), that are retrieved from a .ics calendar file with some parsing operations.. i end up with an array that contains the data i want and then i display it using a tableview..

基本上,我首先需要保存存储在数组中的模块名称,以便下一个t如果用户打开应用程序,则模块名称仍然存在。

Basically i need to initially save the module names that are stored in the array so that the next time the user opens the application, the module names are still there..

为什么使用核心数据
当用户选择一个单元格时在表格视图中(即选择一个模块)我想推送另一个显示该模块名称的视图控制器,用户可以在其中添加应保存的其他数据/字符串。.

Why Core Data When the user selects a cell in tableview (i.e. selects a module) i want to push another view controller that displays the module name where the user can add other data/strings that should be saved..

推荐答案

数组中的对象是什么?它们都是同一类型吗?如果它们是字典,它们是否都具有相同的键?它们由标准属性列表对象(NSDictionary,NSData,NSArray,NSString,NSNumber)组成吗?为什么要使用SQLite数据库而不是用其他方式保存它们?

What are the objects in the array? Are they all the same type? If they're dictionaries, do they all have the same keys? Are they made up of standard property list objects (NSDictionary, NSData, NSArray, NSString, NSNumber)? Why do you want to use an SQLite database rather than saving them some other way?

如果您有一组自定义对象,那么最简单的方法就是实现NSCoding在数组中使用的一个或多个类中。然后,创建一个NSKeyedArchiver并使用-archiveRootObject:toFile:归档您的数组。

If you have an array of custom objects, the simplest thing to do is to implement NSCoding in the class (or classes) used in the array. Then, create an NSKeyedArchiver and archive your array using -archiveRootObject:toFile:.

这篇关于将NSMutable阵列存储到sqlite数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆