2012-04-09 28 views
0

有沒有辦法在應用程序中保存JSON文件,並且每當我需要某些東西時,我都會提出請求並獲得我需要的東西?或者在Core - Data旁邊還有另一種更好的方法? 我想要做的是我的應用程序是要求一些音符,每個音符有它的個別屬性。如果我進入歌曲視圖,我希望能夠用筆記和音節來顯示端口。從我的JSON文件iOS在本地發出請求

段:

"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" 
      }, 
      .... 

任何建議是值得歡迎的。謝謝。

+0

如果你想知道如何來存儲文件,[1] [1]:HTTP: //stackoverflow.com/questions/5619719/write-a-file-on-ios – 2012-04-09 07:52:27

回答

0

您可以嘗試使用NSURLConnection的緩存策略 - 它支持開箱即用,只需調整即可。

0

這正是我需要的:。有一個鏈接]

 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];