2
我从解析中检索多个数组并将它们存储在一个数组中。它目前正在工作,但是当我应用文本[indexpath.row]
时,标签是["cat", "dog"]
,而不是我想要cat, dog
。如何删除数组数组中的[“”]?
var animal: [[String]] = []
if let displayIntake = object["Animal"] as? [String]{
self.animal.append(displayIntake)
print(self.animal)
//prints ["cat", "dog"]
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: TutorBoxCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! BoxCell
cell.info.text = "\(animal[indexPath.item])"
//info is a UILabel
//on the app the label appears ["cat", "dog"] instead I need it to be cat, dog
我得到的错误'无法与类型的String' – stackerleet
此错误的参数列表调用“与分离器加入”消息的装置您正在将'joinWithSeparator'应用于一个字符串,而不是将其应用于数组。 – Moritz
虽然动物被实例化为一个数组。 – stackerleet