16

I've added this function.

- (void) registerWithTouchDispatcher {
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}

error: sharedDispatcher is deprecated

what does it mean and what shall I do?

user1401582
  • 161
  • 1
  • 4

3 Answers3

42

Take a look at ccDeprecated.h, it says to use:

[[CCDirector sharedDirector] touchDispatcher]

thelaws
  • 7,991
  • 6
  • 35
  • 54
16

Change: [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

To: [[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

robbycandra
  • 770
  • 7
  • 6
3

You can check the Cocos2D code behind any Cocos (CC) method by pressing 'Shift+Command' keys and hovering on the method. Doing so on any deprecated method will take you to CCDeprecated.m which will also give you the new method.

appVenture
  • 69
  • 7