Use of undeclared identifier * * *, did you mean * * *. In Xcode

Source: Internet
Author: User

A property isn't the same thing OS a instance variable, you should read a little bit of them, there ' s plenty of sources I n the Internet.

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

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

If you is not confortable with the automaticated instance variable generated, you can always declare your and bind I T 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 if you execute the line above, inside your class, you can either reference to the IVar directly, calling myTextfieldVariable , or b Y the property, self.myTextfieldProperty (there is a few differences actually between them, but I ' m not entering in details).

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

@synthesize myTextfield = _myTextfield;

So, in your case, as a does not synthesize your property, Xcode automatically created the IVar with the underscore in th E beginning. It ' s just a pattern that Xcode follows.

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

@synthesize myTextfield = myTextfield;

i.e. creating a iVar with the same name of the Your property. And why these lines is actyally the same thing? I don ' t know, again, it ' s just a pattern that Xcode follows.

Use of undeclared identifier * * *, did you mean * * *. In Xcode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.