- 浏览: 234206 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (118)
- Ruby/ROR (4)
- Mac (28)
- 我的见闻触发你我的灵感 (1)
- 创业 (1)
- JOSSO (2)
- XML (2)
- OpenRemote (1)
- 娱乐 (2)
- 版权/License (1)
- Java/Spring (4)
- 调试 (1)
- 路由器 (2)
- 技术博客 (21)
- 虚拟机 (1)
- Javascript (6)
- SVN (2)
- HA(Home Automation) (0)
- Android (2)
- iPhone/iPod (23)
- iPad (22)
- iOS公共 (28)
- Windows7 (1)
- 服务器技术 (2)
- 其它 (1)
- Shell (1)
- 数据库 (1)
- 问题总结 (1)
最新评论
-
zjjzmw1:
...
转载:IOS开发之——objectForKey与valueForKey在NSDictionary中的差异 -
hldfxh:
解决了我的问题
JSON Lib, XML转JSON字符串不要namespace,以及处理特殊xml属性"type" -
herry68:
可以给我提供以下你的这个NSData+Base64.h类吗
图片转base64串及反转回图片 -
herry68:
我用这个方法把图片转换成nsstring成功了,但是从nsst ...
图片转base64串及反转回图片 -
hibluse:
handy.wang 写道hibluse 写道我已经设置了WA ...
基于FMDB-SQLite的App数据库性能优化
来自:http://blog.csdn.net/yhawaii/article/details/7442529
nil: A null pointer to an Objective-C object.
( #define nil ((id)0) )
Nil: A null pointer to an Objective-C class.
NULL: A null pointer to anything else, is for C-style memory pointers.
( #define NULL ((void *)0) )
NSNull: A class defines a singleton object used to represent null values in collection objects (which don't allow nil values).
[NSNull null]: The singleton instance of NSNull.
Technically they're all the same,,, but in practice they give someone reading your code some hints about what's going on; just like naming classes with a capital letter and instances with lowercase is recommended, but not required.
If someone sees you passing NULL, they know the receiver expects a C pointer. If they see nil, they know the receiver is expecting an object. If they see Nil, they know the receiver is expecting a class. Readability.
if obj is nil , [obj message] will return NO, without NSException
if obj is NSNull , [obj message will throw a NSException
Demo1:
[NSApp beginSheet:sheet modalForWindow:mainWindow modalDelegate:nil //pointing to an object didEndSelector:NULL //pointing to a non object/class contextInfo:NULL]; //pointing to a non object/class
Demo2:
NSObject *obj1; if (obj1 != nil) { NSLog(@"object is not nil"); }else { NSLog(@"object is nil"); } testClass *c1; if (c1 != Nil) { NSLog(@"class is not Nil"); }else { NSLog(@"class is Nil"); } int *money; if (money != NULL) { NSLog(@"money is not NULL"); }else { NSLog(@"money is NULL"); }
Demo3:
NSObject *obj1 = [[NSObject alloc] init]; NSObject *obj2 = [NSNull null]; NSObject *obj3 = [NSObject new]; NSObject *obj4; NSArray *arr1 = [NSArray arrayWithObjects:obj1, obj2, obj3, obj4, nil]; NSLog(@"arr1 count: %ld", [arr1 count]); //arr1 count: 3 NSObject *obj1; NSObject *obj2 = [[NSObject alloc] init]; NSObject *obj3 = [NSNull null]; NSObject *obj4 = [NSObject new]; NSArray *arr2 = [NSArray arrayWithObjects:obj1, obj2, obj3, obj4, nil]; NSLog(@"arr2 count: %ld", [arr2 count]); //arr2 count: 0
Demo4:
//有异常! NSObject *obj1 = [NSNull null]; NSArray *arr1 = [NSArray arrayWithObjects:@"One", @"TWO", obj1, @"three" ,nil]; for (NSString *str in arr1) { NSLog(@"array object: %@", [str lowercaseString]); } //修改 NSObject *obj1 = [NSNull null]; NSArray *arr1 = [NSArray arrayWithObjects:@"One", @"TWO", obj1, @"three" ,nil]; for (NSString *str in arr1) { if (str != [NSNull null]){ NSLog(@"array object: %@", [str lowercaseString]); } }
发表评论
-
图片转base64串及反转回图片
2013-07-29 12:04 2221图片转base64串: UIImage *_ori ... -
iOS中异步函数的单元测试
2013-06-08 09:51 1478转载自:http://blog.csdn.net/diyag ... -
拆数算法(ObjectiveC递归实现)
2013-03-21 10:45 1870把一个大数拆成几个指定的小数相加,以下实现方式性能很差仅供参考 ... -
[iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端一)
2012-12-16 15:56 8546转载自:http://blog.csdn.net/kangka ... -
复杂数据类型变量的引用计数与block以及__block修饰符的关系
2012-12-14 17:05 4796以下结论是结合参考资料和实验得来,不对地方请大家纠正: ... -
基于FMDB-SQLite的App数据库性能优化
2012-12-14 16:48 110881)如果数据库配置成为串行模式:sqlite3_con ... -
Run Loop
2012-08-24 11:12 1153来源:http://www.cnblogs.com/scorp ... -
转载:IOS开发之——objectForKey与valueForKey在NSDictionary中的差异
2012-08-23 15:49 1270来源:http://blog.csdn.net/pjk1 ... -
深拷贝和浅拷贝
2012-08-23 15:44 913来源:http://blog.csdn.net/pjk1129 ... -
静态全局变量的内存问题
2012-08-23 15:43 1103来源:http://blog.csdn.net/pjk1 ... -
如何将iPhone模拟器的分辨率调整至1136x640?
2012-08-09 10:01 3098来源:http://www.weiphone ... -
AtoS查看iOS Crash log中的16进制代码日志
2012-08-02 17:21 3368注意:crash_log一定要和打包时的archive对应上; ... -
XCODE4.3.2与真机联调时,console里输出中文乱码
2012-07-19 13:34 1280修改项目的scheme的info,把debugger由LLDB ... -
NSAutoReleasePool使用中drain和release的区别
2012-05-30 14:50 1629虽然ARC引入之后NSAutoReleasePool的使 ... -
Network Link Conditioner in Lion
2012-05-21 14:46 1830Network Link Conditioner in ... -
PushMeBaby中的神秘错误代码OSStatus的实际含义
2012-05-03 09:31 75101)查看SecureTransport.h中 / ... -
NSDefaultRunLoopMode vs NSRunLoopCommonModes
2012-04-20 10:14 5284A run loop is a mechanism th ... -
NSParameterAssert
2012-04-20 09:38 2596NSParameterAssert Valida ... -
线程内sleep
2012-04-19 09:20 1004[NSThread sleepForTim ... -
转换Xcode里打印的unicode编码日志
2012-04-18 20:33 17491)打开Terminal 2)输入python 3)pri ...
相关推荐
资源名称:Objective-C学习资料汇总专题资源目录:【】Objective-C NSAutoreleasePool【】Objective-c 中 nil, Nil, NULL和NSNull的区别【】Objective-C 中self 和 super【】Objective-C 的编程之道【】Objective-C_...
相信有不少朋友想知道,在 Objective-C 中 nil 和 Nil 以及 NULL 的区别。最重要的是,在面试中还有不少朋友常会被问到。现在小编在这里统一详细说明。
《Objective-C程序设计》(作者杨正洪、郑齐心、李建国)通过大量的实例系统地介绍了Objective-C语言的基本概念、语法规则、框架、类库及开发环境。读者在阅读本书后,可以掌握Objective-C语言的基本内容,并进行...
Object_C 中的 nil 相当于 NULL 。 Object_C 中的 YES 和 NO 相当于 true 和 false 。 这里再讲解一下 YES 和 NO : Object-c 提供了 BOOL 类型,但这个 BOOL 类型和 C++ 里的并不一样:在 C++ 里一切非 0 值的东西...
Google Objective-C Style Guide 中文版 目录 例子 空格与格式 空格与制表符 行宽 方法声明与定义 方法调用 @public与@private 异常 协议 命名 文件名 Objective-C++ 类名 分类名 Objective-C方法名 变量名 注释 ...
在同一工程中使用 在同一工程中使用 在同一工程中使用 在同一工程中使用 SwiftSwift Swift 和 Objective Objective Objective Objective-C . 39 Mix and Match Mix and Match Mix and Match Mix and Match Mix and ...
主要介绍了iOS中nil、Nil、NULL、NSNull详解的相关资料,需要的朋友可以参考下
IOS 基础之nil,NULL,NSNULL区别详解 ① nil:一般赋值给空对象。 ② NULL:NULL 是一个通用指针(泛型指针)。 一般赋值给 nil 之外的其他空值。如SEL等。 ③ NSNULL:[NSNull null] 是一个对象,他用在不能使用 ...
[map setObject:@"c" forKey:@"content"]; 或者 NSMutableArray *list = [[NSMutableArray alloc]init]; NSMutableDictionary *map1 = [[NSMutableDictionary alloc]init]; [map1 setObject:@"a1" forKey:@...
objective-c小技巧 1. 使用@property和@synthesize声明一个成员变量,给其赋值是时要在前面加上"self.",以便调用成员变量的setmember方法。 直接调用成员变量并且给其赋值:member=[NSString stringWithFormat...
接口在底层的实现有两个部分,type 和 data:- 显式地将nil赋值给接口时:接口 == nil,此时接口的type和data都为nil。type Stu
var noNil = require ( 'no-nil' ) ; var input = [ 1 , undefined ] ; console . log ( noNil ( input ) ) ; // [1]; ##执照 The MIT License (MIT) Copyright (c) 2015 Joseph Spencer Permission is hereby ...
在 Objective-C 或 Ruby 中创建动态网络爬虫。 用法 创建一个刮板: # import " IGScraperKit.h " IGScraper* scraper = [IGScraper scraperWithBlock: ^ id (IGXMLNode* node, NSString * url) { return [[[node...
lua-cjson lua的cjson库 decode略做修改 结果中null还原成nil
n nil:在 C/C++ 你或许曾使用过 NULL,而在 Objective-C 中则是 nil。不同之 处是你可以传递讯息给 nil(例如 [nil message];),这是完全合法的,然而你 却不能对 NULL 如法炮制。 n BOOL:C 没有正式的布尔型别,...