【发布时间】:2017-11-17 03:29:20
【问题描述】:
我有一个 plist,它是一个包含数百个数组的数组,每个数组包含 22 个字符串。如何获取 plist 中每个数组的第一个字符串?
我正在使用集合,在cellForItemAt 中,我试图让数组的第一个字符串显示在标签中的每个单元格下方。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! Collections
// Set Image
cell.imageCell.image = UIImage(named: "image_\(indexPath.row)")
// Check NameLabel Switch Status
if savedSwitchStatus == true {
cell.labelCell.isHidden = false
cell.labelCell.text = (??) // <--------------
} else {
cell.labelCell.isHidden = true
}
return cell
}
我有 2 种类型的 plist:
第一个 plist 有 1 个包含多个字符串的数组。每个字符串都是位于单元格下方的名称。
第二个 plist 是一个数组数组,每个数组包含 22 个字符串。在这里,我只需要从每个数组中获取第一个字符串以显示在单元格下。
【问题讨论】:
-
只需要从plist文件中获取数据并为所欲为stackoverflow.com/questions/1343121/plist-array-to-nsdictionary