Swift convert UInt to Int

前端 未结 4 1597
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 14:19

I have this expression which returns a UInt32:

let randomLetterNumber = arc4random()%26

I want to be able to use the number in

4条回答
  •  暖寄归人
    2020-12-14 14:50

    Int(arc4random_uniform(26)) does two things, one it eliminates the negative results from your current method and second should correctly creat an Int from the result.

提交回复
热议问题