Skip to main content
 首页 » 编程设计

python之什么更接近python None : nil or NULL

2024年10月25日9xiaohuochai

objective-C 中的哪个值更接近 python 中的 None 值?

python: x = None 
 
1)  
obj-C: id x = nil; 
 
2)  
obj-C: id x = NULL; 

请您参考如下方法:

NULL 用于非对象指针; 无效 *。 nil 用于代替 id。 Nil 可以用在任何可以使用 NULL 的地方。所以在我看来这将是 nil 因为 Python 中的 None 表示没有值

NULL (void *)0 literal null value for C pointers

nil (id)0 literal null value for Objective-C objects