2

I have built a loader screen that displays a loading message and a uiprogresview whilst 4 separate data refresh methods are running - each data refresh method has a completed function - which basically adds .25 to the loader as follows -

self.loaderProgress.progress = self.loaderProgress.progress + 0.25;

I want to apply a method that will re-direct from the loader page to the homepage when all refresh methods are complete (when the loader reaches 1).

I'm not sure how to monitor this figure or trigger this method - can anyone recommend a good solution?

Dancer
  • 17,035
  • 38
  • 129
  • 206
  • possible duplicate of [Load new view when UIProgressView is full](http://stackoverflow.com/questions/11569200/load-new-view-when-uiprogressview-is-full) – The dude Apr 29 '14 at 09:58

2 Answers2

2

Keep this logic separate from the progress view - i.e. don't query the progress value from the view. The view is for UI, not for state management.

Instead, do something like keep an array of booleans / jobs to be completed, and mark each one off as it completes. When the list is empty, trigger your completion action.

Wain
  • 118,658
  • 15
  • 128
  • 151
1

Have you tried as like below?

-(void)method1
{
    self.loaderProgress.progress += 0.25;

    if (self.loaderProgress.progress == 1)
        [self done];
}

-(void)method2
{
    self.loaderProgress.progress += 0.25;

    if (self.loaderProgress.progress == 1)
        [self done];
}

-(void)method3
{
    self.loaderProgress.progress += 0.25;

    if (self.loaderProgress.progress == 1)
        [self done];
}

-(void)method4
{
    self.loaderProgress.progress += 0.25;

    if (self.loaderProgress.progress == 1)
        [self done];
}

-(void)done
{
    NSLog(@"Done";
}
Natarajan
  • 3,241
  • 3
  • 17
  • 34
  • Not that this is a good solution, but you really don't need 4 identical methods just with different names... – Wain Apr 29 '14 at 09:26
  • But he said "4 separate data refresh methods are running". – Natarajan Apr 29 '14 at 09:27
  • Each can call the same method when it's complete. You methods just add 0.25 and call another method, there is nothing specific to the triggering operation... – Wain Apr 29 '14 at 09:33