美文网首页iOS Coding程序员
解析plist文件(Objective-C版)

解析plist文件(Objective-C版)

作者: Bug集 | 来源:发表于2015-10-29 21:12 被阅读464次

http://potter528.bj.bdysite.com

self.playlist为播放数组

MusicInfo is Model

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        //每次调用该获取接口内容的方法,先清除播放列表中的旧数据
        [self.playlist removeAllObjects];
        
        NSArray *temparr = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:kPlaylistURL]];
        
        for (NSDictionary *dic in temparr) {
            //创建Music对象
            MusicInfo *music = [MusicInfo new];
            
            [music setValuesForKeysWithDictionary:dic];
            
            [self.playlist addObject:music];
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            //在主线程进行操作
            handler();
        });
    });

相关文章

网友评论

    本文标题:解析plist文件(Objective-C版)

    本文链接:https://www.haomeiwen.com/subject/xckfhttx.html