0

I am at work and don't have the code to hand right now but will post it later, just wanted to see if I could get any answers before I got home.

Basically, I have a tableViewController (view1) with a button on it which pushes to another tableViewController (view2).

the button on view1 checks if the information needed to populate the table on view2 is available. if it is, great, the segue can be performed; if it isn't then the data is stored in the background and then the segue is done.

this does work, but the issue i have is for the 2nd instance, when the data isnt previously saved and the button then saves it, the segue is performed before all of the data is saved in the background, so the table only shows a few records. going back and then pressing the button again solves this as the data has had more time to save and so the table in view2 is up to date.

what i want to do is either stop the segue from happening until all data is saved OR perform the segue and as each record is saved, update the table, so the user can see data is being generated.

i hope that makes some sense!

i can provide code later is needs be.

any suggestions would be great.

thanks

Nick Farrant
  • 207
  • 1
  • 3
  • 10

2 Answers2

0

In this scenario you should create a segue from your first table view controller to second one. Then once you saved your data successfully, you can perform your segue like this

[self performSegueWithIdentifier:@"segueId" sender:self];

You can find more details here: How to perform a segue that is not related to user input in iOS 5?

Community
  • 1
  • 1
anticyclope
  • 1,577
  • 1
  • 10
  • 26
  • But how can I create the condition? For example, how do I code that I dont want the segue to happen until the save is finished? – Nick Farrant Sep 05 '13 at 09:27
  • Since you are controlling save operation, you should know when does it finished. Some of your code could help. – anticyclope Sep 05 '13 at 16:17
0
NSBlockOperation* performSeque = [NSBlockOperation blockOperatioWithBlock:^(){
    [self performSegueWithIdentifier:@"segueId" sender:self];
}];
[performSeque addDependency: [SaveOperation saveOperation]];
[[NSOperationQueue mainQueue] addOperation: performSeque];

Your's seque will be performed as soon as your's save operation will end.

Cy-4AH
  • 4,370
  • 2
  • 15
  • 22