如在m文件中:
@interface KCLoginViewController (){ UITextField *_txtUserName; UITextField *_txtPassword; }
与在h文件中: @property UITextField *_txtUserName; @property UITextField *_txtPassword; 这两种方式有何差异呢?
业精于勤,荒于嬉;行成于思,毁于随。
標準の構文は、下線なしの @property UITextField *txtUserName です。このメソッドは getter setter メソッドを自動的に生成するため、self.txtUserName でアクセスでき、_txtUserName のメンバー変数が作成されます。
UITextField *_txtUserName; UITextField *_txtPassword; } getter setter メソッドは生成されないため、_txtUserName _txtPassword でのみアクセスできます
標準の構文は、下線なしの @property UITextField *txtUserName です。このメソッドは getter setter メソッドを自動的に生成するため、self.txtUserName でアクセスでき、_txtUserName のメンバー変数が作成されます。
そして @interface KCLoginViewController (){UITextField *_txtUserName; UITextField *_txtPassword;
}
getter setter メソッドは生成されないため、_txtUserName _txtPassword でのみアクセスできます