1

I have an application like this:

enter image description here

Now, I want to set the SubscriptionsViewController (first UIViewController on the left) as the delegate of the UserViewController. I have created a @property in the UserViewController.. bla bla bla, but now I can't understand how I can set the first UIViewController as the delegate of the second... If I have a "User" button instad of the "User" UITabBarItem if can do:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UserViewController *userViewController = segue.destinationViewController;
    userViewController.delegate = self;
}

but it doesn't work with UITabBarItems (probably beacause there are no segues (?))

How I can fix this issue?

Thanks!

David H
  • 40,852
  • 12
  • 92
  • 138
Marco Manzoni
  • 707
  • 3
  • 11
  • 21
  • hmm... why do you want to set the delegate? – danqing Aug 15 '12 at 18:42
  • When I press the done button I can do a [self.delegate getNumberOfSubscribersAndViewsForUsername:userRequested]; – Marco Manzoni Aug 15 '12 at 18:46
  • can you just do `someController.delegate = someController.tabBarController`? – danqing Aug 15 '12 at 18:53
  • are you trying to set the delegate to your tab bar controller? – danqing Aug 15 '12 at 19:13
  • No, I want to set the SubscriptionViewController AS the delegate OF the UserViewController. In this way, when I press the "done!" button in the UserViewController I can call a method of the SubscriptionViewController ([self.delegate getNumberOfSubscribersAndViewsForUsername:userRequested];" – Marco Manzoni Aug 15 '12 at 19:18
  • 1
    oh... i see. then you can try `self.delegate = [self.tabBarController.viewControllers objectAtIndex:0];` – danqing Aug 15 '12 at 19:20

0 Answers0