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