-2

I have been trying to figure this out for the last couple of hours and still cannot figure it out or find anything related that might help me out.

I have a method showFriendRequestData and this method makes a server call to get a JSON response. I take my data that I get back and store it into an NSMutableArray. I than make an NSString object and store the total amount of items in the array to a string value.

I then add the value to a UILabel object and try to display it. I have tried calling this method showFriendRequestData in my viewDidAppear method like this.

-(void)viewDidAppear:(BOOL)animated{
    [self showFriendRequestData];
}

But ONLY when I leave the mainViewController and go BACK does the label update..... Make no sense. Am I calling this method I made in the wrong place?? Any help or guidance would be great. I want the label to update the moment I login into my main view controller.

Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
  • How are we supposed to help you without knowing what showFriendRequestData does? – rdelmar Jul 10 '14 at 00:38
  • Which NSString? And how does it relate to the UI? – SwiftArchitect Jul 10 '14 at 00:41
  • Got it figured out, thanks gothic dev! I just added the same thing for ViewWillAppear and it worked just like I wanted it to. @rdelmar I do apologize for not putting more info on that method, it just had a few server things I did not want to reveal. – lollollol Jul 10 '14 at 00:50
  • Shorten, edit and rename that post so that the question and the response do match. – SwiftArchitect Jul 10 '14 at 01:11

1 Answers1

1

You must invoke [super viewDidAppear:animated];

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self showFriendRequestData];
}

Setting your data too late?

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // ...
}

See guidelines-for-viewwillappear-viewdidappear-viewwilldisappear-viewdiddisappear for complete instructions.

Community
  • 1
  • 1
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179
  • I tried that and it still did not work but after doing the same thing for the viewWillAppear it worked, thanks! – lollollol Jul 10 '14 at 00:48