answer:
Finally I use Notifications that I think is a elegant way to do it.
Thanks you Alan.
I have a facebook login (through facebook-ios-sdk) in my tab based app.
I initial "Facebook" in my appDelegate.
I have a "Connect Facebook" UIButton in settingViewController Tab.
I can login facebook through clicking the "Connect Facebook" UIButton (in settingViewController Tab), and then "- (void)fbDidLogin" (in appDelegate) get called.
Everything is fine.
But my question is how to update "Connect Facebook" UIButton (in settingViewController Tab) to "Facebook connected"?
Can I do something like this in appDelegate:
- (void)fbDidLogin
{
NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:[self.facebook accessToken] forKey:@"FBAccessTokenKey"];
[userDefaults setObject:[self.facebook expirationDate] forKey:@"FBExpirationDateKey"];
[userDefaults synchronize];
if (settingViewController) {
settingViewController.facebookButton.text = @"facebook connected";
}
}
Thanks you.
What I have tried:
I put this in settingViewController Tab, but this was not called when the app return from the facebook login screen. So I guess I may have to use delegate in "- (void)fbDidLogin" in appDelegate?
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self checkAccStatusAndUpdateButton];
}