Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift:将UITextField输入转换为字符串,并在特定字符处拆分字符串_Ios_String_Swift - Fatal编程技术网

Ios Swift:将UITextField输入转换为字符串,并在特定字符处拆分字符串

Ios Swift:将UITextField输入转换为字符串,并在特定字符处拆分字符串,ios,string,swift,Ios,String,Swift,我正在尝试将UITextField中的文本转换为字符串,以便对字符串使用方法“ComponentsOperationedByString(“.”),以便将其转换为数组。但我一直收到一个错误,即UITextField没有成员“ComponentsOperationedByString”。有什么建议吗?谢谢 import UIKit import Parse class ViewController: UIViewController { override func didReceiv

我正在尝试将UITextField中的文本转换为字符串,以便对字符串使用方法“ComponentsOperationedByString(“.”),以便将其转换为数组。但我一直收到一个错误,即UITextField没有成员“ComponentsOperationedByString”。有什么建议吗?谢谢

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
是一个
UITextField
而不是
String
。请尝试以下操作:

var username_array: [String] = username.text.componentsSeperatedByString(".")

用户名是一个文本字段。它不应该是username.text,然后调用username_text.componentsOperationedByString(“.”)