Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistent Storage Cocoa/MacOSX

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?

like image 495
Sev Avatar asked Jul 19 '09 09:07

Sev


People also ask

What is persistent storage?

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.

What is the need for persistent 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.

What is the starting point of a Cocoa application?

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.


3 Answers

You can use Core Data and create a persistent store per user (in ~/Library/Application Data/My App/)

like image 99
diederikh Avatar answered Sep 22 '22 01:09

diederikh


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.

like image 35
Jon Steinmetz Avatar answered Sep 21 '22 01:09

Jon Steinmetz


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).

like image 42
knweiss Avatar answered Sep 20 '22 01:09

knweiss