cocoapods – SwiftyJSON和Swift 3:无法转换’Int32’类型的返回表达式?返回类型>’Int?’

前端之家收集整理的这篇文章主要介绍了cocoapods – SwiftyJSON和Swift 3:无法转换’Int32’类型的返回表达式?返回类型>’Int?’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们正在使用 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语句中:

  1. public var int: Int? {
  2. get {
  3. return self.number?.int32Value
  4. }
  5. set {
  6. if let newValue = newValue {
  7. self.object = NSNumber(value: newValue)
  8. } else {
  9. self.object = NSNull()
  10. }
  11. }
  12. }

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

我只需用下面的代码替换一行代码.简单
  1. public var int: Int? {
  2. get {
  3. return self.number?.intValue
  4. }
  5. set {
  6. if let newValue = newValue {
  7. self.object = NSNumber(value: newValue)
  8. } else {
  9. self.object = NSNull()
  10. }
  11. }
  12. }

猜你在找的Swift相关文章