
Question:
i am building an app that requires me to store a number of things.
I have a data object consisting of 4 to 5 BOOL variables, there could be 800 - 1000 such objects which i will need to persist.
Am confused how should i program this, should i go for an sql database or Core data, since NSUserdefaults is not an option obviously.
Answer1:You can easily store them in a plist as @adobels suggested. Your Class would store the BOOLs in a NSNumber and your class implements NSCoding:
- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:member1ToStore forKey:@"yourFirstBoolKey"];
}
- (id)initWithCoder:(NSCoder *)coder ...
If all the instances of your class are in an NSArray (or similar Cocoa Collection) you then simply archive and unarchive to a file like
[NSKeyedArchiver archiveRootObject:yourCollectionOfClasses toFile:archivePath]
[NSKeyedUnarchiver unarchiveObjectWithFile:[[self archiveURL] path]];
See <a href="https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson10.html" rel="nofollow">documentation at apple developer</a> and <a href="https://stackoverflow.com/questions/8727508/ios-persistent-storage-strategy?answertab=active#tab-top" rel="nofollow">this fine answer</a>
Answer2:1000 object can be also stored in plist. Generate a .plist file with 1000 of objects of your type. Then check a performance within your app. If it's ok then your app will simpler to write.