In my app there are two tabbars. In tab-0 parent class is “FirstViewController” and in tab-1 parent class is “SecondViewController”. In “SecondViewController” i have declared protocol and custom delegate method. i want to pass the information in “FirstViewController”(FVC). So FVC has to assigned as a delegate.
Now my doubt is, right now i am in “SVC”. How can i assign “FVC” as a delegate of “SVC”?
In “SVC”
[[self delegate] sendCoordinates:self];
Definition of method is in “FVC”. To execute this method, first i need to assign “FVC” as a delegate.
I hope I am clear in explaining my problem.
Thanks in advance.
You need to set the delegate. Let me demonstrate:
Then, in
SVC.m, you call the delegate in exactly the same way as you showed in your question, so[[self delegate] sendCoordinates:self];Now, in
FVC, you’ll need to#import SVC.hand initialise the object.In the same class, implement
- (void)sendCoordinates:(SVC *)svcand it will be called after you set the delegate.I think you’re missing the
setDelegate:stage, which is why it doesn’t work.Hope it helps!
Note: In SVC, remember to retain the delegate, or it will become
niland no delegate methods will never be called. Don’t forget to release that delegate once you’re done.