I have a modal that displays over a UITableViewController which should display different text in a UITextField placeholder text depending on which UITableViewController called it.
One UITableViewController displays sentences, the other stories. If the modal is pushed on the TableViewController that displays sentences the placeholder should say “Your New Sentence”; if the modal is pushed on the TableViewController that shows Stories it should say “Your Story’s Title”.
I can NSLog the delegate’s name on ViewDidLoad with:
NSLog(@"delegate: %@", self.delegate);
But I’m unsure how to check that with an if statement.
It also feels wrong or inelegant – like it breaks design principles somewhere.
What is an elegant solution to checking which delegate pushed the modal view controller?
The cleanest way is probably to put a property on your custom view controller, and then set it before you present it:
Then, in your view controller’s viewDidLoad you can use the property value to set up the text field.
The modal view controller doesn’t really need to know “who” pushed it; it just needs some information that the “who” should provide when it sets it up.