我有一个块更新每个字符串的视图。在它的对象类由我传递:在块中加入字符串
func eachFeaturesSection(block: ((String?) -> Void)?) {
propertyFeatures.forEach { feature in
guard let feature = feature as? RealmString else {
return
}
let features = feature.stringValue
block?(features)
}
}
,我会得到它ViewController
,通过:
listing!.eachFeaturesSection({ (features) in
print(features)
self.facilities = features!
})
因此,这将打印为:
Optional("String 1")
Optional("String 2")
和self.facilities将设置为最新值,即self.facilities = "String 2"
cell.features.text = features // it will print String 2
那么,我怎样才能实现在一个字符串中加入所有字符串,如self.facilities = "String 1, String 2"
。我用.jointString不起作用。感谢您的任何帮助。
谢谢。但它给出错误说:“类型'[String]'的值在这一行没有成员'加入':cell.features.text = featuresArray.joined(separator:”,“) – Umitk
是的,这工作!featuresArray.joinWithSeparator(” ,“) – Umitk
太棒了,很高兴你得到它的工作:) – pbodsk