首頁| 新聞| 娛樂| 游戲| 科普| 文學| 編程| 系統| 數據庫| 建站| 學院| 產品| 網管| 維修| 辦公| 熱點
NSString *someString = nil;NSURL *someURL = nil;id someObject = nil; if (anotherObject == nil) // do something
// objc.h#ifndef nil# if __has_feature(cxx_nullptr)# define nil nullptr# else# define nil __DARWIN_NULL# endif#endif // __DARWIN_NULL in _types.h #define __DARWIN_NULL ((void *)0)
Class someClass = Nil;Class anotherClass = [NSString class];
// objc.h#ifndef Nil# if __has_feature(cxx_nullptr)# define Nil nullptr# else# define Nil __DARWIN_NULL# endif#endif
int *pointerToInt = NULL;char *pointerToChar = NULL;struct TreeNode *rootNode = NULL;
// in stddef.h#define NULL ((void*)0)
// 因為 nil 被用來用為集合結束的標志,所以 nil 不能存儲在 Foundation 集合里。NSArray *array = [NSArray arrayWithObjects:@"one", @"two", nil]; // 錯誤的使用NSMutableDictionary *dict = [NSMutableDictionary dictionary];[dict setObject:nil forKey:@"someKey"]; // 正確的使用NSMutableDictionary *dict = [NSMutableDictionary dictionary];[dict setObject:[NSNull null] forKey:@"someKey"];
/* NSNull.h Copyright (c) 1994-2012, Apple Inc. All rights reserved.*/ #import <Foundation/NSObject.h> @interface NSNull : NSObject <NSCopying, NSSecureCoding> + (NSNull *)null; @end
nil:指向一個對象的空指針
Nil:指向一個類的空指針
NULL:指向其他類型(如:基本類型、C類型)的空指針
NSNull:通常表示集合中的空值
索泰發布一款GTX 1070 Mini迷
AMD新旗艦顯卡輕松干翻NVIDIA
索泰發布一款GTX 1070 Mini迷你版本:小機
芭蕾舞蹈表演,真實美到極致
下午茶時間,悠然自得的休憩
充斥這繁華奢靡氣息的城市迪拜風景圖片
從山間到田野再到大海美麗的自然風景圖片
肉食主義者的最愛美食烤肉圖片
夏日甜心草莓美食圖片
人逢知己千杯少,喝酒搞笑圖集
搞笑試卷,學生惡搞答題
新聞熱點
疑難解答
圖片精選
使用ASP建設私人搜索引擎
華為短消息中心的發展與應用
移動通信計費及客戶服務系統
移動客戶服務中心系統
網友關注