• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

WhenshouldIusenilandNULLinObjective-C?

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

They differ in their types. They're all zero, but NULL is a void *nil is an id, and Nil is a Class pointer.

各种类型的不存在的表示。

 

理解“不存在”的概念不仅仅是一个哲学的问题,也是一个实际的问题。我们是 有形 宇宙的居民,而原因在于逻辑宇宙的存在不确定性。作为一个逻辑系统的物理体现,电脑面临一个棘手的问题,就是如何用 存在 表达 不存在 .

在 Objective-C 中,有几个不同种类的 不存在。

 

They both are just typecast zero's. Functionally, there's no difference between them. ie.,

#define NULL ((void*)0)
#define nil ((id)0)

There is a difference, but only to yourself and other humans that read the code, the compiler doesn't care.

One more thing nil is an object value while NULL is a generic pointer value.

 

https://stackoverflow.com/questions/1564410/when-should-i-use-nil-and-null-in-objective-c

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Objective-C的基础语法总结发布时间:2022-07-12
下一篇:
Objective-C中的老板是这样发通知的(Notification)发布时间:2022-07-12
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap