Swift3 门店集合

Swift3 门店集合,swift3,xcode8,Swift3,Xcode8,我有一些textField outlet系列。我希望遍历每个集合,并为每个文本字段添加边框。我可以一次成功地收集一个。但是,我不想为每个集合单独调用border函数 我有以下的outletCollections @IBOutlet var nameCollection: [UITextField]! @IBOutlet var phoneCollection: [UITextField]! 这适用于每个系列 for name in nameCollection { someFunct

我有一些textField outlet系列。我希望遍历每个集合,并为每个文本字段添加边框。我可以一次成功地收集一个。但是,我不想为每个集合单独调用border函数

我有以下的outletCollections

@IBOutlet var nameCollection: [UITextField]!
@IBOutlet var phoneCollection: [UITextField]!
这适用于每个系列

for name in nameCollection { 
    someFunction...
    }
我正试着做这样的事情

let collections = [nameCollection, phoneCollection]

for name in collections {
    someFunction...
    }

基本上,我希望提供一个集合列表,并对每个集合的每个成员执行该功能

只需结合您的门店系列:

let combinedCollection = nameCollection + phoneCollection
例如:

extension UITextField
{
    func doSomething()
    {

    }
}

class ViewController: UIViewController {

    @IBOutlet var nameCollection: [UITextField]!
    @IBOutlet var phoneCollection: [UITextField]!

    override func viewDidLoad() {
        super.viewDidLoad()

        let combinedCollection = nameCollection + phoneCollection
        for eachField in combinedCollection
        {
            eachField.doSomething()
        }
    }
}

本例假设每个集合具有相同类型的对象

你面临什么问题,你这样做的错误是什么?