Ambiguous Use of Subscript in Swift

后端 未结 3 1100
暗喜
暗喜 2020-12-10 10:12

I keep getting an error of \"ambiguous use of subscript,\" in my Swift code. I don\'t know what\'s causing this error. It just randomly popped up. Here\'s my code:



        
3条回答
  •  一个人的身影
    2020-12-10 11:04

    ["Key"] has causing this error. New Swift update, you should use objectForKey to get your value. In you case just change the your code to ;

    if let button1Title = currentQuestionDict.objectForKey("choice1") as? String {
        button1.setTitle("\(button1Title)", forState: UIControlState.Normal)
    }
    

提交回复
热议问题