objective-c - 在实现方法中声明变量与在接口文件中声明实例变量有何不同?
迷茫
迷茫 2017-04-24 09:11:44
0
1
461

如在m文件中:

@interface KCLoginViewController (){
UITextField *_txtUserName;
UITextField *_txtPassword;
}

与在h文件中:
@property UITextField *_txtUserName;
@property UITextField *_txtPassword;
这两种方式有何差异呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
阿神

The standard syntax is @property UITextField *txtUserName; without underlining, this method will automatically generate a getter setter method, so it can be accessed with self.txtUserName, and a member variable of _txtUserName will be created,

And @interface KCLoginViewController (){
UITextField *_txtUserName; UITextField *_txtPassword;
}
The getter setter method will not be generated, so you can only access it with _txtUserName _txtPassword

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template