91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

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

玉环县| 长兴县| 遂平县| 太仆寺旗| 关岭| 宜良县| 社旗县| 长岭县| 威远县| 吉林省| 海原县| 宁陵县| 墨脱县| 饶河县| 鄂温| 海安县| 兴业县| 金平| 盖州市| 上林县| 喜德县| 上杭县| 江门市| 蓝山县| 宁强县| 信宜市| 遵义县| 雅江县| 安阳市| 江口县| 石首市| 庆云县| 依兰县| 安新县| 甘肃省| 新邵县| 高碑店市| 金川县| 明光市| 乐至县| 定襄县|