When writing an application for MacOSX, using Cocoa/Objective-C, I'd like to be able to store the data entered by the users. There will only be one user per installation at the moment; however, I'd like to get an idea of how storage methods change if it were multiple users per installation.
In the case of 1 user per installation, should I stick to SQLLite for persistent storage, or what's the recommendation?
If I were to allow for multiple users per installation, what persistent storage method would be prefered?
Persistent storage is any data storage device that retains data after power to that device is shut off. It is also sometimes referred to as nonvolatile storage.
Persistence storage is necessary to be able to keep all our files and data for later use. For instance, a hard disk drive is a perfect example of persistent storage, as it allows us to permanently store a variety of data.
The first thing you need to do is start Xcode. Xcode should be located in /Developer/Applications (the Applications folder inside the Developer folder on your hard-drive). We'll be using Xcode a lot in coming modules so you might like to add it to your Dock now. Launch Xcode by double clicking its icon.
You can use Core Data and create a persistent store per user (in ~/Library/Application Data/My App/)
You could also consider using an NSDictionary as your internal storage mechanism and then write them out to property list files using [NSDictionary writeToFile:atomically:]. A friend of mine likes to refer to dictionaries as God's data structure (tongue in cheek).
If your data size is modest there are several advantages to this: human readable, human writable, changeable.
What kind of data do you want so save? Of course you can still use sqlite to store data for multiple users (e.g. Firefox does this).
But depending on your data you might want to save it into normal files/documents? Take a look at the NSCoding
protocol and the abstract NSCoder
class. Or check out the document architecture (NSDocumentController
, NSDocument
, and NSWindowController
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With