【发布时间】:2014-10-16 07:16:41
【问题描述】:
我是 swift 语言的初学者。我收到此错误:
Error: Any object does not have member named subscript.
谁能给出解决方案?
我的代码:
controller! = UIAlertController(title: "Welcome", message: "Hi...", preferredStyle: .Alert)
let action = UIAlertAction(title: "Please enter atleat 10 characters", style: UIAlertActionStyle.Default, handler: {[weak self] (paramAction:UIAlertAction!) in
let userName = self!.controller!.textFields[0].text
println("your username is \(userName)")
})
controller!.addTextFieldWithConfigurationHandler({(textField:UITextField!) in
textField.placeholder = "XXXXX-XXXXX"
})
【问题讨论】:
-
你是如何声明变量
textFields的? -
实际上该代码在食谱中。我刚打了。我得到了那个错误..你能给出一个正确的代码吗??
标签: objective-c ios7 swift