Before storyboards I was able to set delegates and datasources just by dragging an outlet to a class. With storyboards, I cannot drag the outlet to another view controller; there is no destination that will respond to it.
If I click on a view controller object, I am able to see the class owner at the bottom, but as soon as I select the other view controller containing the outlet, the old selection is gone, so I cannot connect the two.
Is this Apple's way of saying we should only connect them programmatically?
The menu will show a list of properties (including the delegate property) for that object. Then simply right click on the delegate property, hold it, and drag it (a blue line will appear) and link it to the object's delegate.
What is delegate methods in iOS? It is an easy and influential pattern in which one object in a program works on behalf of or in coordination with, another object. The delegating object keeps a reference to the other object and at the suitable time sends a message to it.
An app's storyboard can be easily divided into multiple storyboards, with each one representing an individual story. Best example will be Pre-Login flow. Splash Screen, Login, Signup, Forgot Password, T&C etc can be easily seen as a separate flow independent of the functionalities in the app.
Correct. Set the delegate or other data in your prepareForSegue:sender:
method. Here is an example:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Check the segue identifier if ([segue.identifier isEqualToString:@"showDetail"]) { // Get a reference to your custom view controller CustomViewController *customViewController = segue.destinationViewController; // Set your custom view controller's delegate customViewController.delegate = self; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With