NSNull作用
来源:互联网 发布:隐形眼镜 品牌 知乎 编辑:程序博客网 时间:2024/05/02 04:24
Represent nil with NSNull (摘自官方文档)
It’s not possible to add nil to the collection classes described in this section because nil in Objective-C means “no object.” If you need to represent “no object” in a collection, you can use the NSNull class:
NSArray *array = @[ @"string", @42, [NSNull null] ];
NSNull is a singleton class, which means that the null method will always return the same instance. This means that you can check whether an object in an array is equal to the shared NSNull instance:
for (id object in array) {
if (object == [NSNull null]) {
NSLog(@"Found a null object");
}
}
在NSArray NSDictionary中 nil代表集合类的结束,但是我们又想在集合中添加空位,以备将来用,我们就使用
NSNull 类 它是一个单例类,就是代表一个空对象。
It’s not possible to add nil to the collection classes described in this section because nil in Objective-C means “no object.” If you need to represent “no object” in a collection, you can use the NSNull class:
NSArray *array = @[ @"string", @42, [NSNull null] ];
NSNull is a singleton class, which means that the null method will always return the same instance. This means that you can check whether an object in an array is equal to the shared NSNull instance:
for (id object in array) {
if (object == [NSNull null]) {
NSLog(@"Found a null object");
}
}
在NSArray NSDictionary中 nil代表集合类的结束,但是我们又想在集合中添加空位,以备将来用,我们就使用
NSNull 类 它是一个单例类,就是代表一个空对象。
0 0
- NSNull作用
- NSNull
- NSNull
- NSNull
- NSNull Category
- NSNull Category
- NSString NSNull
- NSNull Category
- iOS NSNull
- NSNull,nil
- 属性readwrite,readonly,assign,retain,copy,nonatomic 各是什么作用,在那种情况下用 ; nil、Nil、NULL、NSNull的区别
- nil Nil NULL NSNull
- NSNULL nil NULL Nil
- nil Nil NULL NSNull
- nil,null,[NSNull null]
- nil / Nil / NULL / NSNull
- nil / Nil / NULL / NSNull
- nil / Nil / NULL / NSNull
- 2014年终总结
- Unity3D学习之(多表连接查询)
- DnsApi简单探索(4) DNS_QUERY_CANCEL struct 及其他
- 树的遍历
- 大学三年半的收支情况
- NSNull作用
- Mybatis XML 文档结构必须从头至尾包含在同一个实体内
- cocos2d-x如何检测碰撞
- HDU1977 Consecutive sum II【水题】
- 【Leetcode】Excel Sheet Column Title
- PLAYGIRLS ~紗倉まな~ 3D 界面汉化+注册表补丁
- [LeetCode] Binary Search Tree Iterator
- EditPlus中文版+英文版+注册码下载
- 再见2014,你好2015!