iOS Xcode配置文件之Geojson文件

来源:互联网 发布:梦幻西游四级回流数据 编辑:程序博客网 时间:2024/05/08 02:23
Geojson文件在Xcode里面就是设计来用来存储Json数据的,用来方便用户配置一些参数。我们可以在Geojson文件中这样存储数据:
{ "programmers": [                                    { "firstName": "Brett", "lastName":"McLaughlin", "email": "aaaa" },                                    { "firstName": "Jason", "lastName":"Hunter", "email": "bbbb" },                                    { "firstName": "Elliotte", "lastName":"Harold", "email": "cccc" }                                    ],        "authors": [                                { "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" },                                { "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" },                                { "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction" }                                ],        "musicians": [                                    { "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" },                                    { "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano" }                                    ]}
然后用的时候,根据文件Path,取出文件,并且解析读取文件相关内容即可,这个解析请看我另外一篇文章。
NSString *strPath = [[NSBundle mainBundle] pathForResource:@"Detail" ofType:@"geojson"];    NSString *parseJason = [[NSString alloc] initWithContentsOfFile:strPath encoding:NSUTF8StringEncoding error:nil];

1 0
原创粉丝点击