且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将NSMutable阵列存储到sqlite数据库中

更新时间:2022-04-23 02:40:03

数组中的对象是什么?它们都是同一类型吗?如果它们是字典,它们是否都具有相同的键?它们由标准属性列表对象(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:.