The difference between nil and null and Nilde in iOS development ———— and how to determine the relationship of a connected object

Source: Internet
Author: User

Nil indicates that an object pointer is null for the object

> Sample code:
NSString *somestring = nil;
Nsurl *someurl = nil;
ID someobject = nil;
if (Anotherobject = = nil)//do something

Nil indicates that a class pointer is empty, for class

> Sample code:

Class SomeClass = Nil;
Class Anotherclass = [NSString class];

Null indicates that the base data type is empty, base type

> Sample code:
int *pointertoint = NULL;
char *pointertochar = NULL;
struct TreeNode *rootnode = NULL;

NSNull: An object in the collection object that represents a null value.

Http://ios.itcast.cn/news/20141015/1633199713.shtml has a detailed explanation on this website;

In the development of the project we often have to determine whether the content of two is the same or whether it is empty. For example, we have a uitextfile in which nothing is written as empty, which is a special case; it's not written in the box, but it's still a matter of whether it's nil or not, and some of it is a special case. The default is to get a string, even if you don't write anything in it. He is also a string. The special case of looking at the API will fall into the tangle.

Pay attention to the usual writing

The difference between nil and null and Nilde in iOS development ———— and how to determine the relationship of a connected object

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.