2

I need to wait (don't execute the code) after the presentModalViewController until the modal view it's dismissed, it's possible or it's a conceptual error ?

-(NSDictionary *)authRequired
{
    //This view write the settings when dismissed (plist)
    [self presentModalViewController:loginRegView animated:YES]; 
    //Read from the setting file (plist) and send back (it's a delagate method)
    NSMutableDictionary *ret=[[NSMutableDictionary alloc] init];
    [ret setObject:[app.settings get:@"user"] forKey:@"user"];
    [ret setObject:[app.settings get:@"pass"] forKey:@"pass"];
    return ret;
}
Cesar
  • 4,418
  • 2
  • 31
  • 37
  • 1
    I'm not sure what your exact question is. Could you restate it? – Chris Cooper May 10 '10 at 02:49
  • 1
    after the call to presentModalViewController the code execution continues. I would like to execute the line after that call only after dismissing the view. – Cesar May 10 '10 at 03:48

2 Answers2

0

What you'll have to do is create a LoginRegViewControllerDelegate protocol to which the View Controller that presents the Modal View Controller adheres, and have your LoginRegViewController (or whatever its name is) send a message to its delegate that it just closed / is going to close. In this delegate method, your delegate View Controller should read the just-set settings and do whatever it wants with them.

Douwe Maan
  • 6,888
  • 2
  • 34
  • 35
0

To make your child view controller (modal view) more flexible and reusable you can use NSNotificationCenter. Here's the class reference.

Your modal view should post a notification, that it is going to be closed. Any other controller, that should react on this notification should add an observer to the same notification center.

Dmitriy
  • 1,852
  • 4
  • 15
  • 33