0

I have a custom UIViewController, called BoardViewController, and I have subclassed this to create GameBoardViewController. I added an NSNotificationCenter observer in viewDidLoad of BoardViewController. When I segue from another view controller to GameBoardViewController it seems this observer is duplicated somehow. Because now, whenever I cause that particular notification to be posted, the method called from the observer is called twice. I have tested making GameBoardViewController the initial view controller in the storyboard and there are no issues. It only happens when I segue to it.

Thanks for any help you can provide.

BoardViewController:

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gameBoardTileWasTapped:) name:@"gameBoardTileWasTapped" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(log:) name:nil object:nil];
}

GameBoardViewController:

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view.
}
Patrick Veilleux
  • 471
  • 1
  • 4
  • 17
  • Can you show the viewDidLoad method of the BoardViewController and GameBoardViewController classes? – yoninja Nov 07 '13 at 03:13
  • @yoninja As you can see in the code I added it is pretty straight forward. Maybe I am not understanding something basic about segues but it doesn't seem like `gameBoardTileWasTapped:` would get called twice from one observer. Thanks – Patrick Veilleux Nov 07 '13 at 21:29

0 Answers0