What's the difference between nil, NULL, nil, and Nsnull under iOS you made it?
Source: Internet
Author: User
<span id="Label3">Nil<p>Defines a null pointer to an object in OC that has an empty instance.<br>NSString *somestring = nil;<br>Nsurl *someurl = nil;<br>It is best to assign them to nil when you release a certain object, which ensures security and can cause the program to crash if you do not assign Nil.</p>Null<p>Null can be used on various pointers in the C language<br>#define __darwin_null<br>#define__DARWIN_NULLConstants<br>int *pointertoint = NULL;<br>Char *pointertochar = NULL;<br>struct TreeNode *rootnode = NULL;<br>In objective-c, the Nil object is designed to be associated with a null null Pointer. The difference is that nil is an object, and null is just a Value. and we're not going to generate crash or throw exceptions for the nil call Method.</p>Nil<p>To define an empty class<br>Class SomeClass = Nil;<br>Class Anotherclass = [nsstring class];</p>NSNull<p>The collection object cannot contain nil as its specific value, such as nsarray, nsset, and Nsdictionary. accordingly, The nil value is represented by a specific object Nsnull. Nsnull provides a single instance for representing the nil value in the Object's properties. The default implementation method, Dictionarywithvaluesforkeys: and setvaluesforkeyswithdictionary: automatically converts nsnull and nil to each other, so your object does not need to perform nsnull test operations.</p><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p><p>What's the difference between nil, NULL, nil, and Nsnull under iOS you made it?</p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service