Reputation: 4636
After I completed the tutorial: Start Developing iOS Apps Today
I got the same exception asked here: IOS Tutorial Exception (ToDo Sample) and the app crashed but it would not crash if I started a debugging session and stepped through the code.
2015-05-04 16:09:51.569 ToDoList[9223:67681] -[AddToDoItemViewController textField:]: unrecognized selector sent to instance 0x7fe570d4eff0
2015-05-04 16:09:51.574 ToDoList[9223:67681] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AddToDoItemViewController textField:]: unrecognized selector sent to instance 0x7fe570d4eff0'
Then I solved the mystery by reading out this post: IOS Tutorial Exception (ToDo Sample)
The reason was that I wrongly connected the text field to the @implemenation section instead of to the @interface section and it created some method that I deleted. Of course I forgot about that soon after that.
How could I have figured out myself without knowing anything of the above what was the reason to get that exception and where it came from?
Upvotes: 0
Views: 98
Reputation: 3873
Log message is telling you that something was trying to call -textField:
method of your AddToDoItemViewController
.
So the first step would be to check if that method is implemented - in your case it was not. You might have been confused by the presence of
@property(weak, nonatomic) IBOutlet UITextField* textField
but auto synthesis for property generates getter with the signature -textField
, which is different from -textField:
(latter takes one parameter, while former none).
Upvotes: 2
Reputation: 4163
The exception says that you're trying to access the textView
property of AddToDoItemViewController
, but it doesn't have one.
So your next step would've been to go and check that you have a property like that declared and being an outlet that it's properly connected in the Interface Builder.
Edit:
Sorry I wasn't paying enough attention.
The selector that it's trying to call is textField:
so it must be a function starting like that. I assume you set the controller as a TextView delegate but didn't implement the required method.
Upvotes: 0