网络:Plist 解析

来源:互联网 发布:网络有声小说配音兼职 编辑:程序博客网 时间:2024/06/10 02:48
#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    [self locolPlist];}// 本地的plist 文件- (void)locolPlist {    // 路径    NSString *path = [[NSBundle mainBundle]pathForResource:@"videos.plist" ofType:nil];    // 数组    NSArray *data = [NSArray arrayWithContentsOfFile:path];    NSLog(@"%@",data);}// 网络的plist文件// plist解析了解一下就可以- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {    // NSURL    NSURL *url = [NSURL URLWithString:@"http://localhost/videos.plist"];    // 创建请求    NSURLRequest *request = [NSURLRequest requestWithURL:url];    // 发送异步    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {//        NSLog(@"%@",data);//        NSJSONSerialization        // 解析plist 文件        id result = [NSPropertyListSerialization propertyListWithData:data options:0 format:NULL error:NULL];//        NSLog(@"%@",result);    }];}@end
0 0
原创粉丝点击