Instance variable 'variable' accessed in class method error
If you meant to make this an instance method, change that + to -.
1. For + (void)hit
:Only have access to the self
object.
--Step 1: Remove follwing line from header file
@property (nonatomic, readwrite) int _nPerfectSlides;
--Step 2:
- Add
int _nPerfectSlides
in your class file globally.. - That means declare before
@implementation
Eg: In .m File
#import "Controller.h"
int _nPerfectSlides // Add like this before @implementation
@implementation Controller
2. For - (void)hit
:Only have access to the instance methods
An instance variable is, as its name suggests, only accessible in the instance methods (those declared with -
). Class methods (declared with +
) have no access to instance variable, no more than they have access to the self
object.