I'm trying to check if a text field is enabled or not in Objective-C on Xcode. (note: enabled is different from not empty)
if([_firstTextField.userInteractionEnabled == NO]){
I'm trying to check if a text field is enabled or not in Objective-C on Xcode. (note: enabled is different from not empty)
if([_firstTextField.userInteractionEnabled == NO]){
UITextField
is enabled
by default. You can use isEnabled
Property :
if(YOUR_TEXT_FIELD.isEnabled) {
}
And further to disable:
YOUR_TEXT_FIELD.enabled = NO;
Update:
enabled
is a property of UIControl
, which is the superclass for UIButton. userInteractionEnabled
is a property of UIView
(which is the superclass of UIControl). enabled has effects on the visual state of the object (greyed out, by default) and is generally the preferred method of disabling a control—visual feedback indicating behaviours is a good thing.
There's not much practical upshot beyond that. Code that interacts with your controls is more likely to check if buttons are enabled than if their userInteractionEnabled
property is set; it's more conventional.
The code I used was right, i just needed to remove the Square Brackets!
if(_firstTextField.userInteractionEnabled == NO)
ROOKIE MISTAKE.