The appDelegate application needs some sort of way to find out who the viewController is hosting, so it can send a dismissal message. You need to figure out how to do this. One way is to define ivar on appDelegate "callDismissOnMeIfFaceBookFails" and set it when you are in this situation, otherwise its nil.
Please note that if its nil, appDelegate can send a letter of resignation without any overhead, no problem! Use nil messaging to your advantage (I use it all the time). [Beyond this: I see so much code "if (obj) [obj message];" Do not make if messages - just send a message - if obj is zero, it has no effect and is processed efficiently!]
EDIT:
So you have the AppDelegate class. In #interface, define a property:
@property (nonatomic, strong) UIViewController *callDismissOnMeIfFaceBookFails;
and in implementation you are @synthesize. Define a method:
- (void)dismissLoginView { [callDismissOnMeIfFaceBookFails dismissModalViewControllerAnimated:YES]; callDismissOnMeIfFaceBookFails = nil;
So, before presenting a modal view controller, the representing object sets the appDelegate property "callDismissOnMeIfFaceBookFails" for itself.
When the user has successfully logged in, the login object sends an appDelegate message, which notifies the rejectLoginView function.
source share