use of undeclared identifier *** , did you mean ***. in xcode

A property is not the same thing os a instance variable, you should read a little bit of them, there's plenty of sources in the internet.

Summarizing, a property is the combination of the instance variable (by default, automaticated declaraded with a underscore), and it's get and set methods.

To access the property inside your class, you should call for self.propertyName, in your case it would be self.myTextfield. This will access the gererated get method of the property. You can always, of course if you are inside the class, skip the get method and access the variable directly. In this case, it would be _myTextfield.

If you are not confortable with this automaticated instance variable generated, you can always declare your own and bind it with the property with the @synthesize command. Like this:

@synthesize myTextfieldProperty = myTextfieldVariable;

Here's more information about the synthesize. As I said before, this command binds one iVar to a property. So, when you execute the line above, inside your class, you can either reference to the iVar directly, calling myTextfieldVariable, or by the property, self.myTextfieldProperty (there are a few differences actually between them, but I'm not entering in details).

If you don't write the synthesize, what xcode does for you, automatically, is this:

@synthesize myTextfield = _myTextfield;

So, in your case, as you does not synthesize your property, xcode automatically created the iVar with the underscore in the beginning. It's just a pattern that xcode follows.

The line @synthesize myTextfield;, without binding an iVar directly, is simple the same as

@synthesize myTextfield = myTextfield;

i.e. you are creating an iVar with the same name of your property. And why these two lines are actyally the same thing? I don't know, again, it's just a pattern that xcode follows.

转载于:https://www.cnblogs.com/welhzh/p/4322835.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值