swift ? must be followed by a call, member lookup, or subscript

后端 未结 3 707
臣服心动
臣服心动 2021-01-07 23:41

I think I\'m looking at some outdated code:

@IBAction func stockLevelDidChange(sender: AnyObject) {
        if var currentCell = sender as? UIView {
                 


        
相关标签:
3条回答
  • 2021-01-08 00:32

    The problem is the if let newValue = textfield.text.toInt()? { .. If toInt() returns an Int? then just get rid of the ? there.

    0 讨论(0)
  • 2021-01-08 00:35

    In 1.2, toInt is gone. So,

    if let newValue = textfield.text.toInt()?
    

    Should be replaced with:

    if let newValue:Int? = Int(textField.text!)
    
    0 讨论(0)
  • 2021-01-08 00:41

    Actually the as? are all fine. The problem is this line:

    if let id = cell.productId?
    

    Just remove the question mark at the end of that. It makes no sense.

    0 讨论(0)
提交回复
热议问题