Instance variable 'variable' accessed in class method error

后端 未结 4 1975
长发绾君心
长发绾君心 2020-12-14 09:03

I have a variable declared in the header file :

@interface

int _nPerfectSlides;

and

@property (nonatomic, readwri         


        
4条回答
  •  醉酒成梦
    2020-12-14 09:27

    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

提交回复
热议问题