【发布时间】:2015-09-22 19:58:16
【问题描述】:
我的集合视图单元格中有一个按钮,用于将索引路径中的项目保存到解析的用户类中的数组属性。集合视图由事件填充,用户单击弹出警报视图的按钮,当他们单击“是”时,事件将保存到用户将参加的事件数组中。
在 cellForRowAtIndexPath 方法中,我将目标添加到按钮并调用弹出警报视图方法,这一切都很好......
cell.attendButton.addTarget(self, action: "popAlertView", forControlEvents: UIControlEvents.TouchUpInside)
现在方法内部是我遇到一些问题的地方......
方法(let event...)的第二行有一个错误,指出“任何对象都没有名为 row 的成员”。访问索引路径并为相应的事件实例化事件的最佳方法是什么?
func popAlertView() {
var indexPath = self.collectionView.indexPathsForSelectedItems()
let event = events[indexPath?.row]
var alertViewController = UIAlertController(title: "Attend event?", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
alertViewController.addAction(UIAlertAction(title: "Yes!", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
// save event to array of events of user
}))
alertViewController.addAction(UIAlertAction(title: "No thanks", style: UIAlertActionStyle.Cancel, handler: { (action) -> Void in
}))
self.presentViewController(alertViewController, animated: true) { () -> Void in
// finish up here
}
}
另外,在事件数组(用户类)的保存事件中,我该如何以数组形式保存和检索 PFUser.currentUser 的对象?我查看了 Parse 的开发人员指南,但找不到太多可以帮助我解决的问题,只能保存单个对象。
我对 swift 和 parse 还很陌生,所以感谢您的耐心和帮助!
【问题讨论】:
标签: swift parse-platform uicollectionviewcell