tableView:didSelectRowAtIndexPath: call to current-view Parser delegates

守給你的承諾、 提交于 2019-12-06 15:53:36

what do I do here to get tempModArray back up to tableView:didSelectRowAtIndexPath: method

Short answer: you don't.

didSelectRow has already done his job which is to inform the app that the user selected the row. Now the app has some work to do. Namely, figure out if it's going to push a new view controller with data, or not. So don't push, decide if there's data, and then pop; rather, don't push in the first place if there's no data.

At the point where your parser knows whether it has data or not, you have lots of options. I'm assuming your parser delegate is not in your table view controller class. You can:

  • Post an NSNotification that your table view controller is listening for, and the listening method can either push the detail view controller if there's data, or no-op if there's not. You can pass the array in the notification.
  • Call a method directly on your table view controller to push the detail view controller, passing in the array (declare a protocol in your table view controller header and have the parser delegate call into that method)
  • Push the detail view controller directly from the parser (kind of icky)
  • Use KVO

imo the protocol method is the cleanest, (loose coupling but with good naming), but each to their own.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!