您的位置:首页 > 运维架构

iOS之NSJSONReadingOptions的三个选项

2016-06-23 15:50 363 查看
定义如下

typedef NS_OPTIONS(NSUInteger, NSJSONReadingOptions) {
NSJSONReadingMutableContainers = (1UL << 0),
NSJSONReadingMutableLeaves = (1UL << 1),
NSJSONReadingAllowFragments = (1UL << 2)
}


官方文档

Constants
NSJSONReadingMutableContainers
Specifies that arrays and dictionaries are created as mutable objects.

Available in iOS 5.0 and later.
NSJSONReadingMutableLeaves
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.

Available in iOS 5.0 and later.
NSJSONReadingAllowFragments
Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary.

Available in iOS 5.0 and later.


翻译

<span style="color:#006600;">/*

NSJSONReadingMutableContainers
// 指定数组和自定创建为可变的对象
Specifies that arrays and dictionaries are created as mutable objects.

Available in iOS 5.0 and later.

NSJSONReadingMutableLeaves
// 指定返回json对象内部的字符串为可变字符串的实例
Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.

Available in iOS 5.0 and later.
NSJSONReadingAllowFragments
// 指定解析的时候允许最外层(最顶层)的对象可以不是一个数组或字典对象也是可以的
Specifies that the parser(解析) should allow top-level objects that are not an instance of NSArray or NSDictionary.

Available in iOS 5.0 and later.
*/</span>

三个选项是可以结合同时使用的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息