ios中的plist文件为数组里面为字典数组包含四个元素,字典又包括两个属性 如下图分别为NSString 和NSArray,第二层array下面依然是一个字典数组,每个字典包含对应的属性,现已经将数据显示到一个tableView里面,如下图
现在想获得数组musics里面的值,包括歌曲名和歌手名以及歌曲的链接,请问该如何获取到数据
PHP中文网2017-04-17 16:29:42
In fact, this kind of problem belongs to the problem of peeling garlic. . It peeled off with some patience.
The whole thing is an array, right?
items = [@item0,@teim1,@item2, @item3];
Look at the attributes of item0 and continue peeling the garlic
NSDictionary *item = items[0];
Look at the attributes of music under item0 and continue peeling the garlic
NSArray *musics = item[@"musics"]
Then continue to peel the garlic.... For this type of question, just peel the garlic based on the attributes, But I generally don’t recommend this method of playing, it is not intuitive and easy to make mistakes. Modify the data structure and the whole person will be sb. Peel the garlic again.
https://github.com/icanzilb/JSONModel
A project to model data, similar to GSON in Java. Although the efficiency is average, it is very easy to use, much easier to use than those with high efficiency. 大家讲道理2017-04-17 16:29:42
Get the array with key=music in item0
Then get the dictionary based on index from this array
Then get it from the dictionary based on key