Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7796325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:20:28+00:00 2026-06-01T23:20:28+00:00

I have built a UITableViewController for my app which interacts with my core data

  • 0

I have built a UITableViewController for my app which interacts with my core data model. It’s primary purpose is to be pushed onto the navigation controller and display a list of entities and allow me to edit / select and drill down into info them etc…

However, elsewhere in my app, I now want to modally display a simple picker to select one of these entities. I think the best way to implement this is building a protocol to handle the picker that can send messages back to my delegate about whether the user cancelled or selected an entity etc…

As so much of the coding will be the same, my question is this: is it possible/or in any way advisable to enable the UITableViewController as a protocol?

i.e. when displayed normally, it behaves as it does currently (a standard subclass of UIViewController) but then is also able to be presented modally by a delegate and pass messages to a delegate?

Keen to her thoughts on best practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:20:30+00:00Added an answer on June 1, 2026 at 11:20 pm

    You don’t even need a formal protocol. Just give your UITableViewController a @property (nonatomic, assign) id delegate when instantiating it from the other controller. Set that as the delegate. Use id to not couple your classes too tightly and do not retain the delegate.

    Implement two methods for didCancelPicking...:(id)sender and didPick...:(id)sender item:(id)pickedItem in the calling controller.

    Now when viewing the UITableViewController modally you need to do two things. Supply a cancel button + react to that (didCancelPicking...) and probably modify tableView:didSelectRowAtIndexPath: to send didPick... to the delegate. Always test the delegate with respondsToSelector: and in case it does performSelector:withObject:. Always put the sender as the first argument in these delegate methods.

    Also, always show and hide the modal controller from the calling class. Do not let it remove itself from a UINavigationController for instance.

    These are the best practices I can think off the top of my hat.

    Regarding your specific code reuse here: You have to decide if your code gets too messy, when you reuse that UITableViewController and want to change how it behaves when shown modally. E.g. you might later want to prevent editing and drilling down in that case. You could of course always encapsulate this in if (self.delegate) checks, but…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a data driven model by dragging my tables onto the empty
I have built and app which does random stuff and I want to collect
I have a navigation controller app. I created a RootViewController class with Xib file.
I have built an application in which I use sqlite to store data. It
I have 8 cells that are being built in my UITableViewController. I would like
I have built an app that plays lots of sounds the easy way: AudioServicesPlaySystemSound(someSoundID);
I have a UITableViewController that when loaded gets data from a web-service and stores
i have built application using codeigniter, my controller name is userReg , in controller
I have built a Fiddle on JSFiddle which retrieves an OAuth access token via
I have built a one page web application that manipulates a set of data:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.