0
我试图将UITextField中的文本转换为字符串,以便我可以在字符串上使用方法“componentsSeperatedByString(”。“) 。?它变成一个数组,但我不断收到一个错误的UITextField没有成员“componentsSeperatedByString”任何意见,感谢Swift:将UITextField输入转换为字符串并在特定字符处拆分字符串
import UIKit
import Parse
class ViewController: UIViewController {
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutlet weak var username: UITextField!
@IBOutlet weak var password: UITextField!
//Login function. Drag Down keyboard after clicking login
@IBAction func Login(sender: AnyObject) {
username.resignFirstResponder()
password.resignFirstResponder()
var username_array: [String] = username.componentsSeperatedByString(".")
}
}
用户名是一个文本框不应该是username.text,然后调用username_text.componentsSeperatedByString(“。”) – Divya