1

So I go back to my view controller from my skscene using the following ANSWER from a previous question I have asked. But now since ios8 I now get an error saying. Has anyone else dealt with this since the release of ios8 how did they fix it?

'NSInvalidArgumentException', reason: '-[TCAMyScene setDelegate:]: unrecognized selector sent to instance 0x79485190'

Now from this answer Delegate not found I have tried changing

theScene.delegate = self;

to..

[(TCAMyScene *)theScene setDelegate:self];

but I still get the same error. This is the warning im getting.. enter image description here

Community
  • 1
  • 1
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
  • Does TCAMyScene inherit from SKScene? And are you running this on an iOS 8 simulator/device? The delegate method is available only in iOS 8.0 onwards. – CodeSmile Nov 18 '14 at 18:30
  • Well mixed behaviours in ios7 the app will crash with the error I gave about and iOS8 it won't crash on that delegate line but when it comes to calling [self.mySceneDelegate mySceneDidFinish:self]; from my scene to go back to the vc nothing happens.Sorry if the question was confusing I meant to say since the release of ios8 this issue happens @LearnCocos2D and im running from iOS 7 and 8 simulators – 4GetFullOf Nov 18 '14 at 18:45
  • and yes TCAMyScene inherits from SKScene @LearnCocos2D – 4GetFullOf Nov 18 '14 at 19:00
  • 3
    Did you add `@property (nonatomic, weak> id delegate;` to the `@interface` of `TCAMyScene`? Also, `SKScene` class (and its subclasses) already has a `delegate` property. You should rename your `delegate` to something like `myDelegate`. – 0x141E Nov 18 '14 at 21:19
  • I have done both those things I have found that solution also in another answer but it didn't help @0x141E – 4GetFullOf Nov 19 '14 at 16:01
  • 1
    If you changed `delegate` to `myDelegate`, the assignment statement should be `((TCAMyScene)theScene).myDelegate = self;` or `[(TCAMyScene)theScene setMyDelegate:self];`. Also, add `` to your view controller's `.h` file if you haven't already done so. – 0x141E Nov 19 '14 at 17:21
  • Thank you! You can go ahead and put this as the answer ((TCAMyScene *)theScene).mySceneDelegate = self; after changing the name i never changed the assignment statement! ill mark it as correct! @0x141E – 4GetFullOf Nov 19 '14 at 18:11

1 Answers1

1

The assignment statement should be

    ((TCAMyScene)theScene).myDelegate = self;

or

    [(TCAMyScene)theScene setMyDelegate:self];

if you changed the delegate to myDelegate,

0x141E
  • 12,613
  • 2
  • 41
  • 54