我得到了一个错误,如下所述:
Could not cast value of type 'table_vIEw.UsertableVIEwController' (0x10a1991b0) to 'NSIndexPath' (0x10a5e8438).
UserRecordVIEwController是VIEw Controller,用于显示个人详细信息.而InsertRecordVIEwController是另一个VIEw Controller.
UsertableVIEwController相关代码:
func tableVIEw(tableVIEw: UItableVIEw,editactionsForRowAtIndexPath indexPath: NSIndexPath) -> [UItableVIEwRowAction]? { // 1 let editaction = UItableVIEwRowAction(style: UItableVIEwRowActionStyle.Default,Title: "Edit",handler: { (action:UItableVIEwRowAction,indexPath:NSIndexPath) -> VoID in self.performSegueWithIDentifIEr("editSegue",sender: self) }) editaction.backgroundcolor = UIcolor.darkGraycolor() // let editIndex = editaction.indexOfAccessibilityElement(indexPath.row) let deleteAction = UItableVIEwRowAction(style: UItableVIEwRowActionStyle.Default,Title: "Delete",indexPath:NSIndexPath) -> VoID in let userInfo: UserInfo = self.marrUserData.objectAtIndex(indexPath.row) as! UserInfo let isDeleted = ModelManager.getInstance().deleteUserData(userInfo) if isDeleted { Util.invokeAlertMethod("",strBody: "Record deleted successfully.",delegate: nil) } else { Util.invokeAlertMethod("",strBody: "Error in deleting record.",delegate: nil) } self.getUserData() }) deleteAction.backgroundcolor = UIcolor.lightGraycolor() return [deleteAction,editaction]}overrIDe func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) { if(segue.IDentifIEr == "editSegue"){ let selectedindexPath = sender as! NSIndexPath let index = selectedindexPath.row //if let indexPath: NSIndexPath = self.tableVIEw.indexPathForCell(sender as! UItableVIEwCell) { //let btnEdit : UIbutton = sender as! UIbutton //let selectedindex : Int = btnEdit.tag let vIEwController : InsertRecordVIEwController = segue.destinationVIEwController as! InsertRecordVIEwController vIEwController.isEdit = true vIEwController.userData = self.marrUserData.objectAtIndex(index) as! UserInfo // } }}
我想知道我哪里出错了.伙计们好吗?
提前致谢!!
解决方法 导致错误的行是:let selectedindexPath = sender as! NSIndexPathSender是SelectedCell,而不是IndexPath!
在行self.performSegueWithIDentifIEr(“editSegue”,sender:self)之前,将类的属性(selectedindexPath)设置为indexPath,然后从prepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?)访问此属性.
另一种方法可以在:https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson9.html#//apple_ref/doc/uid/TP40015214-CH9-SW1找到
总结以上是内存溢出为你收集整理的ios – 在swift中滑动以编辑sqlite数据库内容全部内容,希望文章能够帮你解决ios – 在swift中滑动以编辑sqlite数据库内容所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)