0

I'm calling a method I've written in app delegate which calls an alertView to ask the user for a password, I use the method in applicationWillEnterForeground also.

So the value is set in clickedButtonAtIndex in app delegate.

How do I determine when the value has been set in the view controller (where I'm calling the method) ?

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
Jules
  • 7,568
  • 14
  • 102
  • 186

1 Answers1

1

The simplest way to do this would be to delegate back to your viewController.

Your app delegate will have the ability to access the pointers to any ViewControllers/navControllers that you have. (scope depends on your design of course)

Here is a good Post on objective-c delegates.

I found myself doing this kind of thing quite often to simplify the process i had a method contained in a singleton that i called 'toolbox' that went something like this.

-(void)showAlertWithTitle:(NSString*)_title Message:(NSString*)_message CancelButtonTitle:(NSString*)_cancelTitle AlternitiveButtonTitle:(NSString*)alternitiveButtonTitle AndDelegate:(id)del
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:_title message:_message  delegate:del cancelButtonTitle:_cancelTitle otherButtonTitles:alternitiveButtonTitle, nil];

[alert show];
[alert release];
}

This meant that i could call an alert where i wanted and have the Alert delegate back to where i wanted, then just implement UIAlertViewDelegate there.

Community
  • 1
  • 1
Luke Mcneice
  • 3,012
  • 4
  • 38
  • 50