Search code examples
delegatessprite-kitskscene

delegate works in xcode 5 but not in xcode 6


@property (unsafe_unretained,nonatomic) id<SceneDelegate> delegate; 

it works fine on xcode 5, but it gives me this error on xcode 6.1

Error: Property type 'id<SceneDelegate>' is incompatible with type 'id<SKSceneDelegate>' inherited from 'SKScene'

what's that mean?

Addition:

beginning of scene.h

@protocol SceneDelegate <NSObject>
- (void) eventStart;

@end

@interface Scene : SKScene<SKPhysicsContactDelegate>

@property (unsafe_unretained,nonatomic) id<SceneDelegate> delegate;

viewController.h

#import "Scene.h"
#import <AVFoundation/AVFoundation.h>


@interface ViewController : UIViewController<SceneDelegate, AVAudioPlayerDelegate>

viewController.m

scene.delegate = self;

That's all the lines contain SceneDelegate.


Solution

  • It means SKScene already has a property of the same name: delegate

    You are trying to redeclare that property but with a different protocol: SceneDelegate instead of SKSceneDelegate.

    So either you wanted to use the delegate property, in that case you needn't declare that property, just assign your SKSceneDelegate object to the delegate property. For example:

    self.delegate = mySceneDelegateObject;
    

    Otherwise use a different name instead of delegate if SceneDelegate is an actual protocol you created (and consider renaming the protocol because it's easily confused with SKSceneDelegate).