无法从Swift中的collectionview中访问Core Data对象

时间:2015-09-06 09:35:07

标签: ios swift core-data

我在这个问题上摸不着头脑。

我一直得到以下错误:

'NSInvalidArgumentException', reason: '-[_NSFaultingMutableSet objectAtIndex:]: unrecognized selector sent to instance
     

0x7ff3ec6b4590'

当我尝试从我的集合视图中访问Photo Core Data模型时。

 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! PinViewCollectionViewCell

      println(selectedPin!.attachedPhotos.count) // Returns 3
      println(selectedPin!.attachedPhotos[indexPath.row]) 
//^^Returns NSInvalidArgumentException', reason: '-[_NSFaultingMutableSet objectAtIndex:]:  
//unrecognized selector sent to instance 0x7ff3ec6b4590'

             return cell

任何想法如何访问attachmentPhotos个别项目?

1 个答案:

答案 0 :(得分:1)

试试这个;

println((selectedPin!.attachedPhotos.allObjects as! NSArray)[indexPath.row]);