Swift converting between UInt and Int

后端 未结 5 1113
我寻月下人不归
我寻月下人不归 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:33

    Add this anywhere outside of a class:

    extension UInt {
        /// SwiftExtensionKit
        var toInt: Int { return Int(self) }
    }
    

    Then just call:

    self.photos[index].toInt
    

提交回复
热议问题