Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IDMah

macrumors 6502
Original poster
May 13, 2011
317
11
Hi all.

I have 2 UIViewControllers with tableviews. on a scrollview.

UIController 0: is LocalHighScore.
UIController 1: is GlobalHighScore.

They have a method: loadHighScores: (int) where (int) tells it what file to load and reloads the data.

How do call the Method(s) on Global HighScore controller from the top level UIViewController??
ps. Global HighScore is offscreen. (does that even matter?)

thanks.
 
Last edited:
Hi all.

I have 2 UIViewControllers with tableviews. on a scrollview.

UIController 0: is LocalHighScore.
UIController 1: is GlobalHighScore.

They have a method: loadHighScores: (int) where (int) tells it what file to load and reloads the data.

How do call the Method(s) on Global HighScore controller?? which is offscreen. (does that even matter?)

thanks.

It depends on how your app is structured. How do you load the global high score view controller? Do you create it with a segue, and let it get released when you move to a different VC? Or do you create your GlobalHighScore VC at launch and keep it around?

One option is to make your loadHighScores method a class method rather than an instance method. That way you can call it even if there is not currently an instance of the GlobalHighScore in memory.

Another option would be to move those methods out of your VCs and into a singleton utilities class.
 
Why not wait for sync to happen ???

Quick and dirty answer was to Create something that tells the View
Which HighScore Screen it was on:

Code:
HighScoreController.h
NSInteger highScoreIdent;


HighScoreController.m
// and then also add in View //

- (void)viewDidLoad
{
 // Stuff and more Stuff // 
// then did //
 [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(reloadHighScores)
                                                 name:@"PLEASEVIEWTOUPDATE"     
                                                object:nil];

}

-(void) reloadHighScores
{
    if (highScoreIdent>0) {
        [self loadHighScores:1]; 
        // which loads the data from"worldHighScoreTable"
    }
}

// And then when the Server Load Push the Notification // 

HighScoreGetter.m

- (void)fetchedData:(NSData *)responseData 
{
  // get all the stuff // 
 //  and when done // 
  [[NSNotificationCenter defaultCenter] postNotificationName:@"PLEASEVIEWTOUPDATE" object:nil];
}

Why I couldn't think of this before also Stumps me... feels a little Hacky but works..

Hope this Helps someone else..
but more than likely you're smarter than me. HAHaha!!!

Thanks everyone.
 
It's was more about waiting for the data to load from the server.
and then reloading the nsuserdefaults, might have been able to use that
but this makes sense to my little brain.

Also differentiating between the LocalHighsScore and GlobalHighScore
thanks
Ian
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.