1

It has been some months that I've programmed for iOS, and want to finish my game with new features. Now when people play the game and lose they will see a "Game Over" view.

Now what I want is that people first see a view where they can use the bought credits they gotten and go back to the game with the extra seconds or life. But I'm not doing it on the right way.

Way I'm trying to do:

          - Save Me View (Segue)
Game view - 
          - Game Over View (Segue)

So, you lose, go automatically to the save me view, presses close and go to game over immediately. Otherwise use the NSUserDefaults that has been saved before showing the Save Me view.

So I'm using NSUserDefaults for saving previous game levels/points etc and that is not the right way of doing and the flow is getting complicated.

Second try: I've tried it but I'm stuck at the last step. Because I'm using Segue's and delegates, I don't know how to make my GameView the delegate of the SaveView, while the protocols are already there.. I've followed this: Passing Data between View Controllers

Now at step 6 it doesn't work because i'm using modal segue's with my UIViewControllers and no UINavigationControllers. I've this in my code atm:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([[segue identifier] isEqualToString:@"SaveMe"]){

        SaveMeViewController *vc = [segue destinationViewController];
        // Here needs to come that GameView (This Class) is the delegate for SaveMeViewController. Tried vc.delegate = self; but this doesn't work.
        [self savePoints];
    }
}
Community
  • 1
  • 1
Kets
  • 438
  • 2
  • 8
  • 24

2 Answers2

1

You could setup a delegate in the gave view that passes back how the game ended.

Jbryson
  • 2,875
  • 1
  • 31
  • 53
  • Thanks, tried it but I'm stuck at the last step. Because I'm using Segue's and delegates, I don't know how to make my GameView the delegate of the SaveView, while the protocols are already there.. I've followed this: http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers I'll edit my OP – Kets Feb 13 '15 at 12:56
-1

As my understanding use @property or delegate to pass data it will help you.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
if ([segue.identifier isEqualToString:@"SaveMe"]) {
    SaveMeViewController * vc = segue.destinationViewController;
// create property in SaveMeViewController and access that property and pass values
    vc.property = value to assgin;
  }
}
Pallavi Ligade
  • 529
  • 3
  • 14
  • Yeah that's what i'm doing, but I'm now creating a delegate to passing the data back, and for passing the data back, i need to figure out how to make GameView the delegate of SaveGame to get data back. – Kets Feb 13 '15 at 13:23