Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS在本地发出请求_Ios_Request_Local - Fatal编程技术网

iOS在本地发出请求

iOS在本地发出请求,ios,request,local,Ios,Request,Local,有没有办法在我的应用程序中保存一个JSON文件,每当我需要什么东西时,我都会发出请求并得到我需要的东西?或者除了核心数据,还有其他更好的方法? 我想用我的应用程序做的是请求一些音符,每个音符都有各自的属性。如果我转到歌曲视图,我希望显示带有音符和音节的便携词 我的JSON文件中的代码段: "notes":[ { "note_type" : "0", "note_syllable1" :

有没有办法在我的应用程序中保存一个JSON文件,每当我需要什么东西时,我都会发出请求并得到我需要的东西?或者除了核心数据,还有其他更好的方法? 我想用我的应用程序做的是请求一些音符,每个音符都有各自的属性。如果我转到歌曲视图,我希望显示带有音符和音节的便携词

我的JSON文件中的代码段:

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

欢迎提出任何建议。谢谢。

您可以尝试使用NSURLConnection的缓存策略-它是现成支持的,只需调整它。

这正是我所需要的:

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

如果您想知道如何存储文件,[这里有一个链接][1][1]: