Reputation: 4083
In one of my view controllers, the following function is called after a button is clicked, so that I can do some initialization and pop the current view (ResultViewController
) and display the previous view (GameViewController
).
- (IBAction)PlayNextList:(id)sender {
NSInteger index = [[[GameStore defaultStore] allLists] indexOfObjectIdenticalTo:[[GameStore defaultStore] selectedList] ];
if(index == [[[GameStore defaultStore] allLists] count]-1)
{
index = 0;
}
index++;
[[GameStore defaultStore] setSelectedList:[[[GameStore defaultStore] allLists] objectAtIndex:index]];
[[GameStore defaultStore] resetGame];
[[GameStore defaultStore] createResult];
NSLog(@"Press Next List");
NSLog(@"%@",[[[[GameStore defaultStore] allLists] objectAtIndex:index] label]);
[[self navigationController] popViewControllerAnimated:YES];
}
On iPhone/iPod, I noticed that [[GameStore defaultStore] createResult];
is being called twice but it's only being called once on iPad.
After trying to figure out why it's being called twice, I found out that the second call happened between viewWillAppear
and viewDidAppear
of the GameViewController
.
Any idea why this is happening?
Upvotes: 2
Views: 1120
Reputation: 10083
Make sure to check the connections inspector for the event that fires to activate PlayNextList, especially if you have different NIB files for iPhone and iPad, and make sure that event is not wired up twice to the same method.
Upvotes: 2