Reputation: 799
Okay, so I'm trying to make this action change a user-editable textfield if the textfield is empty. This is the code i'm using right now, but it won't work:
if ([textField.text isEqualToString:[NSString stringWithFormat:@""]]) {
[o1 setText:[NSString stringWithFormat:@"1"]];
Anybody know why? I did this as well:
UITextField *textField;
Is that necessary?
UPDATE: I just realized I should have put this in here earlier, but it's for ios, not mac. Sorry!
Upvotes: 0
Views: 1160
Reputation: 4164
Your code is somewhat convoluted - just test like so:
if ([myTextField length] == 0) myTextField.text = @"1";
You need to declare myTextField in the interface like so:
IBOutlet UITextField *myTextField;
then link it in IB. You could make it a property to simplify memory management.
Upvotes: 1