久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Swift 中將 Int 轉(zhuǎn)換為字符

How to convert an Int to a Character in Swift(如何在 Swift 中將 Int 轉(zhuǎn)換為字符)
本文介紹了如何在 Swift 中將 Int 轉(zhuǎn)換為字符的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我在這里掙扎和失敗了十多分鐘,我屈服了.我需要在 Swift 中將 Int 轉(zhuǎn)換為 Character,但無法解決.

I've struggled and failed for over ten minutes here and I give in. I need to convert an Int to a Character in Swift and cannot solve it.

問題

你如何將一個(gè) Int (integer) 轉(zhuǎn)換 (cast) 為一個(gè) Character (char) 在 Swift 中?

How do you convert (cast) an Int (integer) to a Character (char) in Swift?

說明性問題/任務(wù)挑戰(zhàn)

生成一個(gè) for 循環(huán),打印字母 'A' 到 'Z',例如像這樣:

Generate a for loop which prints the letters 'A' through 'Z', e.g. something like this:

    for(var i:Int=0;i<26;i++) {      //Important to note - I know 
        print(Character('A' + i));   //this is horrendous syntax...
    }                                //just trying to illustrate! :)

推薦答案

不能將整數(shù)直接轉(zhuǎn)換為 Character 實(shí)例,但可以從整數(shù)轉(zhuǎn)換為 UnicodeScalarCharacter 并再次返回:

You can't convert an integer directly to a Character instance, but you can go from integer to UnicodeScalar to Character and back again:

let startingValue = Int(("A" as UnicodeScalar).value) // 65
for i in 0 ..< 26 {
    print(Character(UnicodeScalar(i + startingValue)))
}

這篇關(guān)于如何在 Swift 中將 Int 轉(zhuǎn)換為字符的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw stars using Quartz Core?(如何使用 Quartz Core 繪制星星?)
Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?(為什么給 addArcWithCenter 一個(gè) 0 度的 startAngle 使它從 90 度開始?)
Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在與中心點(diǎn)成給定角度的直線相交的 UIView 矩形上找到 CGPoint)
Which is the best way to estimate measure of photographed things?(哪種方法是估計(jì)拍攝物體尺寸的最佳方法?)
Convert Character to Int in Swift 2.0(在 Swift 2.0 中將字符轉(zhuǎn)換為 Int)
Edit Text shows exception Invalid Int quot;quot;(編輯文本顯示異常 Invalid Int “;)
主站蜘蛛池模板: 亚洲欧美在线播放 | 亚洲免费大片 | 可以在线观看的av | 免费一级黄色片 | 4438成人网| 久久久久成人网 | 午夜视频免费观看 | 成人免费毛片嘿嘿连载视频 | 色中色综合| av网站免费在线观看 | 黄视频免费观看 | 69av在线| 国产免费小视频 | 欧美国产视频 | www.桃色 | 特级做a爱片免费69 伊人超碰在线 | 国产超碰在线 | 操操操干干干 | 日韩中文字幕在线视频 | 国产精品麻豆视频 | 亚洲 欧美 激情 另类 校园 | 视频爱爱免费视频爱爱太爽 | 成人爽a毛片一区二区免费 亚洲午夜在线观看 | 久久久婷 | 亚洲二级片 | 亚洲色综合 | 久久999| 久久久久国产视频 | 亚洲69视频 | 婷婷色婷婷 | 精品一区二区国产 | 国产超级av | 这里都是精品 | 色综合一区二区 | 精品视频免费观看 | 欧美自拍视频 | 欧美精品日韩 | 99精品久久久 | 亚洲欧美精品在线 | 久久免费国产视频 | 欧美性猛交99久久久久99按摩 |