Swift converting between UInt and Int

后端 未结 5 1111
我寻月下人不归
我寻月下人不归 2020-12-30 18:52

I have the following methods

var photos = [MWPhoto] = [MWPhoto]()

func numberOfPhotosInPhotoBrowser(photoBrowser: MWPhotoBrowser!) -> UInt {

    return          


        
5条回答
  •  隐瞒了意图╮
    2020-12-30 19:37

    If you want unsigned int from negative value use UInt(bitPattern:)

    let intVal = -1
    let uintVal = UInt(bitPattern: intVal) // uintVal == 0xffffffffffffffff
    

提交回复
热议问题