Question

I am making a note-taking app but this app won't be a traditional note-taking application. This application will be used by my company's employees and engineer teams in my company. The notes content will be large because contain some mathematical expressions. Also, files must be sent to dropbox as text and pdf files.

I wonder which is the best method of these for storing large data content:

1- Simply writing notes content to file (like note1.txt) in Documents directory

I am using this function for writing files:

-(IBAction)writeFile:(id)sender
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *fileNameData=[NSString stringWithFormat:@"%@.txt",fileName.text];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileNameData];

    NSString *str = fileContent.text;

    [str writeToFile:filePath atomically:TRUE encoding:NSUTF8StringEncoding error:NULL];
} 

2- Or storing file contents in database and create a file when user wants to send the note to dropbox and send this created file to dropbox?

I have created note-taking apps before but in this one, files will be large and I am worried about performance.

UPDATE

I did some trials. I tried to write and read the same string using both technique; core data and files.

It takes about 16 seconds to read string from Core Data and about 5 seconds to read from the file with stringWithContentsOfFile method.

I know that is not very accurate results but I guess Core Data is not very proper for me. If I am wrong, please correct me.

Was it helpful?

Solution 2

Core data is a pain the in butt to get setup and working. Do you have a incredibly large data set or need to do entity relationship between the files?

If not I would just have a dictionary or array that contains a simple object that has meta data about the file (last access time, title, file location, etc) I would then load this dictionary and use it in a table view for selecting the files.

The files themselves can be loose files on disk in the data directory. To improve the performance of saving just copy the string and then just write it out asynchronously using GCD. When a user selects one file to open again load it using GCD and show a small progress bar. if these files are small it will be close to instant for loading.

OTHER TIPS

Well this should be done using core data Core Data Usage and for the benefits please read this SO question Why should I use Core Data for my iPhone app?

I made a Notes App myself and used core data and it works fine . Hope this helps.

EDIT : Or check this link Relating to the Data Storage guidelines. It includes all types of guidelines as given by Apple.

CoreData would be quicker than read/write to files. But, you are not worried about performnace when you write to file. You are worried about Performance when you send the files to dropbox How frequent is that? If that is done not so frequently like once a day , then may be text files is a better option than coredata or sqlite.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top