加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocoapods – SwiftyJSON和Swift 3:无法转换’Int32’类型的返

发布时间:2020-12-14 05:25:14 所属栏目:百科 来源:网络整理
导读:我们正在使用 CocoaPods配置pod’ SwiftyJSON’,’3.1.0’升级到SwiftyJSON Swift 3. 我们收到此错误: /Users/xxx/Documents/iOS/xxx/Pods/SwiftyJSON/Source/SwiftyJSON.swift:866:33: Cannot convert return expression of type ‘Int32?’ to return typ
我们正在使用 CocoaPods配置pod’ SwiftyJSON’,’3.1.0’升级到SwiftyJSON Swift 3.

我们收到此错误:

/Users/xxx/Documents/iOS/xxx/Pods/SwiftyJSON/Source/SwiftyJSON.swift:866:33:
Cannot convert return expression of type ‘Int32?’ to return type
‘Int?’

错误在SwiftyJSON.swift的return语句中:

public var int: Int? {
    get {
        return self.number?.int32Value
    }
    set {
        if let newValue = newValue {
            self.object = NSNumber(value: newValue)
        } else {
            self.object = NSNull()
        }
    }
}

谁知道问题是什么?这是我们的CocoaPods配置还是使用SwiftyJSON的问题?

我只需用下面的代码替换一行代码.简单
public var int: Int? {
        get {
            return self.number?.intValue
        }
        set {
            if let newValue = newValue {
                self.object = NSNumber(value: newValue)
            } else {
                self.object = NSNull()
            }
        }
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读