2015-09-06 116 views
0

我在这个问题上摸不着头脑。无法从Swift的collectionview中访问核心数据对象

我不断收到以下errror:

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

0x7ff3ec6b4590'

当我尝试从我的集合视图中访问照片核心数据模型。

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 

任何想法如何我可以访问附加的照片个别项目?

+1

最有可能的'attachPhotos'是一个'(NS)集'而不是一个数组。 –

回答

1

试试这个;

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

这工作作为附加照片是NS设置,但能够将其转换为使用上述快速原生。作为[照片] –