How can I do this?
I have ViewController 1, and ViewController 2.
ViewController 1 defines a protocol and ViewController 2 conforms to it.
I set ViewController 2 has a delegate and invoke a method in ViewController 1. This method runs fine. And send confirmation back to my ViewController 2.
I can exchange data between them, but I’m trying to figure out a way, to get data from a particular instance of ViewController 1, to ViewController 2.
Because when I’m using my delegate, to run a method in ViewController 1 it’s not going for that particular instance that I’m interested in.
Is there a way I can resolve this?
Can I set my delegate, a delegate of a particular instance so I can get it’s state? Is this possible? And if so, how?
In other words, can I target a specific instance with my delegate?
—
p.s. if I try to get data of a property ruled by ViewController 1, it come has nil (I think this is because I’m not targeting a particular instance)! One way I can resolve it, is have a method that reads “already saved data”. But I would be replicating code, and instantiating new objects with data that is already available in previous ViewControllers.
Any help is most appreciated. Thank you in advance!
Nuno
edit:
SetupTableViewController *delegate = [[SetupTableViewController alloc] init];
[delegate setDelegate:self];
Every property I try to get from this point on forward, is nil. How can I target this to a particular instance of my previous ViewController? I do not want to instantiate a new SetupViewController. What I really need is to access an existing instance of my SetupViewController.
The question is really vague and you should probably post some code to better explain what you’re trying to achieve.
Well when you do myViewController1Instance.delegate = self; , any delegate call that you make will only be sent from myViewController1Instance object to ViewController2, not from the other instances of ViewController1 class.