func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(identifier, forIndexPath: indexPath) as! ComposeCell
cell.deletePictureSignal.subscribeNext { (response) -> Void in
print("delete picture")
let deleteIndex = (self.pictureView.indexPathForCell(cell)?.item)!
self.pictures.removeAtIndex(deleteIndex)
// self.pictureView.reloadData()
}
cell.addPictureSignal.subscribeNext { (response) -> Void in
print("add picture")
self.selectedIndex = (self.pictureView.indexPathForCell(cell)?.item)!
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)
}
return cell
}
データをリロードすると、この方法が再び実装され、Signal が何度もサブスクライブされます。