Reputation: 1264
I'm new in objective-c and my problem is that in (xcode) the Parent UIViewController is monitoring Ibeacon's and when the user go to the Child UIViewController the monitoring is still running and I need to call a Child VC method from the Parent. Like if the Actual Closest Beacon is changed, I want to alert the user that "Hey! You moved! etc.". Is there a proper way to do it? (Sorry for the bad english and if I'm not so specific)
Upvotes: 1
Views: 617
Reputation: 6263
If your parent has only one child:
MyChildController* child = self.childViewControllers[0];
[child yourMethod];
Upvotes: 0
Reputation: 7549
There are several ways to do it.
Your ParentViewController could keep pointer to your ChildViewController and call its function, which you would write in ChildViewController, something like showUserAlert. Once this is fired, you can show the alert.
Have the ParentViewController fire an NSNotification
from
NSNotificationCenter
. The child should listen to it and act
accordingly.
I would obviously go for the first one.
Upvotes: 2