Why must I define variables twice in the Header file?

后端 未结 3 1964
不知归路
不知归路 2021-01-21 08:42

Why must I define variables twice in the header file? What differences are there between these variables?

The first definition is here:

@interface MyCont         


        
3条回答
  •  星月不相逢
    2021-01-21 09:00

    In modern runtime you do NOT need to declare them twice. Just use:

    In you .h

    @property (nonatomic) NSInteger selectedIndex;
    

    The part between the {} is the declaration of the iVar. And with your @property you declare getter and setters. In modern runtime if you just use the code above you say basicly the same (your iVar is now _selectedIndex).

提交回复
热议问题