use of undeclared identifier "shouldAutorotate"

Xcode says that the "shouldAutorotate" code is undeclared. But I don't write this code. It is supplied by Apple, isn't it. This is the code:

SKView * skView = (SKView *)self.view;

skView.showsFPS = YES;

skView.showsNodeCount = YES;

/ Sprite Kit applies additional optimizations to improve rendering performance */

skView.ignoresSiblingOrder = YES;

/

GameScene *scene = [GameScene nodeWithFileNamed:@"GameScene"];

scene.scaleMode = SKSceneScaleModeAspectFill;

/

[skView presentScene:@"scene"]; //Another error:"incompatible pointer types sending 'NSString*' to parameter of type 'SKScene _Nullable'"

- (BOOL)shouldAutorotate{ // Error in this line :"Use of undeclared identifier 'shouldAutorotate' "

return YES;

}


Please help me. Thank you.

Please help me. Thank you.

Did you import UIKit ?

Yes.

Seems that shouldAutororate is now a property and no more a func.


So you should override the var shouldAutororate.


See: http : / / stackoverflow.com/questions/38721302/shouldautorotate-function-in-xcode-8-beta-4

Thanks for the explanation and the website. But the code of the website is in Swift and I am using Objective C. Sorry I didn't tell you before. And I understand some of them but not all. Do you have other explanations? Thank you

I'm not fluent in objC, so I can only post what I read :


to override a property accessors :


- (void)setHidden:(BOOL)hidden {
    super.hidden = hidden;
    [self invalidateIntrinsicContentSize];
}


http : / / stackoverflow.com/questions/31782896/swift-override-property-set-hidden-like-objectivec

Accepted Answer

I've compiled the boolean in the viewDidLoad method. So I moved it out and the error is fixed. Thanks for help

Don't forget to mark the thread as solved by clicking a "Correct Answer" button. That helps keep the forum clean.

use of undeclared identifier "shouldAutorotate"
 
 
Q