user2408952
user2408952

Reputation: 2041

Can't get UITextField variable

I'm trying to change the color of some placeholder text, of a UITextField, but i having problems reaching the text field. I've created a property with Referencing Outlets, like this:

@property (retain, nonatomic) IBOutlet UITextField *usernameField;

But can't reach it with either usernameField or _usernameField. What am i missing?

Upvotes: 0

Views: 222

Answers (3)

Harunmughal
Harunmughal

Reputation: 367

enter image description hereYou can check it. Have you connected the outlet of the textfield in the xib file?

Upvotes: 0

Aladdin Gallas
Aladdin Gallas

Reputation: 701

first you should use self.usernameField and second just make sure you assigned the outlet to the UITextField you need to access it in the Interface Builder.

Upvotes: 0

Duncan C
Duncan C

Reputation: 131418

If you have a property, do NOT synthesize it. That just complicates things, and is no longer needed in Objective C 2.0.

Don't use _usernameField. That bypasses the property getter/setter and accesses the iVar directly.

Use self.usernameField instead. Until you understand the difference, use the property except in the code of a custom getter/setter or dealloc method.

Upvotes: 3

Related Questions