中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

IOS 開發之ObjectiveC的變量類型的字符代表

發布時間:2020-10-22 20:59:41 來源:腳本之家 閱讀:166 作者:lqh 欄目:移動開發

IOS 開發之ObjectiveC的變量類型的字符代表

實例代碼:

NSDictionary *dic = @{@"1":[NSNumber numberWithBool:YES], 
                @"2":[NSNumber numberWithChar:'1'], 
                @"3":[NSNumber numberWithDouble:2.0], 
                @"4":[NSNumber numberWithFloat:2.0f], 
                @"5":[NSNumber numberWithInt:1], 
                @"6":[NSNumber numberWithInteger:2], 
                @"7":[NSNumber numberWithLong:30], 
                @"8":[NSNumber numberWithLongLong:3], 
                @"9":[NSNumber numberWithShort:4], 
                @"10":[NSNumber numberWithUnsignedChar:'1'], 
                @"11":[NSNumber numberWithUnsignedInt:3], 
                @"12":[NSNumber numberWithUnsignedInteger:35], 
                @"13":[NSNumber numberWithUnsignedLong:45], 
                @"14":[NSNumber numberWithUnsignedLongLong:59], 
                @"15":[NSNumber numberWithUnsignedShort:4] 
                }; 
    for(NSString *key in dic){ 
      id value = [dic valueForKey:key]; 
      if([value isKindOfClass:[NSNumber class]]){ 
        const charchar * pObjCType = [((NSNumber*)value) objCType]; 
        NSLog(@"%@,%s",key,pObjCType); 
      } 
    } 

以上的輸出結果證明:

UnsignedChar  =>s 
Char      =>c 
UnsignedShort  =>i 
LongLong    =>d 
UnsignedInt   =>q 
Float      =>f 
Int       =>i 
UnsignedInteger =>q 
Integer     =>q 
UnsignedLong  =>q 
Long      =>q 
LongLong    =>q 
UnsignedLongLong=>q 
Bool      =>c 
Short      =>s 
double     =>d 



再看以下代碼,用@encode關鍵字的

NSLog(@"1=>%s",@encode(BOOL)); 
NSLog(@"2=>%s",@encode(char)); 
NSLog(@"3=>%s",@encode(double)); 
NSLog(@"4=>%s",@encode(float)); 
NSLog(@"5=>%s",@encode(int)); 
NSLog(@"6=>%s",@encode(NSInteger)); 
NSLog(@"7=>%s",@encode(long)); 
NSLog(@"8=>%s",@encode(long long)); 
NSLog(@"9=>%s",@encode(short)); 
NSLog(@"10=>%s",@encode(unsigned char)); 
NSLog(@"11=>%s",@encode(unsigned int)); 
NSLog(@"12=>%s",@encode(unsigned long));//unsigned NSInteger 
NSLog(@"13=>%s",@encode(unsigned long)); 
NSLog(@"14=>%s",@encode(unsigned long long)); 
NSLog(@"15=>%s",@encode(unsigned short)); 

以上的輸出結果證明:

BOOL=>c 
 char=>c 
 double=>d 
 float=>f 
 int=>i 
 NSInteger=>q 
 long=>q 
 long long=>q 
 short=>s 
 unsigned char=>C 
 unsigned int=>I 
 unsigned NSInteger=>Q 
 unsigned long=>Q 
 unsigned long long=>Q 
 unsigned short=>S 

讀者可以根據這種方式來判斷某個變量到底屬于哪種類型。

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

鸡西市| 武平县| 江口县| 丽水市| 汝阳县| 兴城市| 九江市| 永宁县| 宜宾县| 忻州市| 东平县| 牟定县| 景东| 上栗县| 孟村| 开鲁县| 龙泉市| 古田县| 宾阳县| 自治县| 肃南| 宜昌市| 石棉县| 贞丰县| 拜城县| 文山县| 德保县| 玛曲县| 广水市| 鞍山市| 镇宁| 娄底市| 塔河县| 思茅市| 延庆县| 当雄县| 黄浦区| 平南县| 阜新| 兴国县| 榕江县|