Here are the areas of concern in my class:
.h
@interface TimerViewController : UIViewController <UITextFieldDelegate> {
IBOutlet UITextField *hourField,*minuteField;
}
@property (strong, nonatomic) IBOutlet UITextField *hourField,*minuteField;
@end
.m
@implementation TimerViewController
@synthesize hourField,minuteField;
@end
My issue is that I can use the text fields multiple times (retrieve and set properties) before the app crashes with this log:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSCFString setText:]: unrecognized selector sent to instance 0x1e1dafa0'
This happens when the code [self.hourField setText:@"5"]; is run. It can also happen when checking if [self.hourField isFirstResponder] with the same type of log.
The console sees the text field as a __NSCFString which leads me to think it may have been released?
Runs with ARC, and I’m always using synthesised accessors. Never had this issue before and can’t see where I’m going wrong.
I think the problem may be a confusion with how you declared the variables. You do not need the @synthesize statement anymore and and normally you would want to have your private iVars have a different spelling than your property declarations. To see if this is the problem remove both your @property declaration and your @synthesize and access hourField simply as [hourField setText:@”5″]; . Another way would be to remove the @synthesize and the iVar declarations altogether.
Other I would check are whether the IBOutlet is connected to the right item in your .xib or storyboard.