需要将NSData转换为NSArray [英] Need to convert NSData to NSArray

查看:124
本文介绍了需要将NSData转换为NSArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NSURLConnection从URL下拉一个plist,它返回
NSData对象。我想将其转换为NSArray。任何人都可以帮助我吗?

I am pulling down a plist from a URL using an NSURLConnection, which returns an NSData object. I would like to convert this to an NSArray. Can anyone help me?

我正在重构一个方法,该方法当前对URL执行同步请求,
使用arrayWithContentsOfURL:来获取NSArray。

I am refactoring a method that currently does a synchronous request to the URL, using arrayWithContentsOfURL: to get the NSArray.

谢谢!!

推荐答案

使用 + [NSPropertyListSerialization dataWithPropertyList:format:options:error:] 转换数据,然后检查结果 -isKindOfClass:[NSArray class]

Use +[NSPropertyListSerialization dataWithPropertyList:format:options:error:] to convert the data, then check if the result -isKindOfClass:[NSArray class].

这篇关于需要将NSData转换为NSArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆