0

Is there a way to save a JSON file within my app and whenever I need something, I would make a request and get what I need? Or maybe there is another better way beside Core - Data? What I am trying to do with my app is to request for some musical notes, each note having it's individual properties. I would like that if I go to a song-view, to display the portatives with notes and syllables.

Snippet from my JSON file :

 "notes":[   
            {
                    "note_type" : "0",
                    "note_syllable1" : "Twink",
                    "note_syllable2" : null,
                    "note_length" : "0"
            },
            {
                    "note_type" : "0",
                    "note_syllable1" : "le,",
                    "note_syllable2" : null,
                    "note_length" : "0"
            },
            ....

Any suggestion is welcome. Thanks.

Teo
  • 3,394
  • 11
  • 43
  • 73
  • If you want to know how to store a file, [there is a link.][1] [1]: http://stackoverflow.com/questions/5619719/write-a-file-on-ios – Tech Agent Apr 09 '12 at 07:52

2 Answers2

0

You can try to use caching policies of NSURLConnection - it's supported out of box, just tune it.

Denis
  • 6,313
  • 1
  • 28
  • 27
0

This is exactly what I needed :

     NSString *responseString = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"testmodel" ofType:@"json"] 
                                                           encoding:NSUTF8StringEncoding error:nil];
     SBJsonParser *parser = [[SBJsonParser alloc] init];
     NSDictionary *responseDictionary = [parser objectWithString:responseString];
Teo
  • 3,394
  • 11
  • 43
  • 73