I am newbie in iOS programming, Recently I came across a tutorial where author assigned a ViewController to a textField delegate. Is it good to do this? As Xcode is giving me warning.
discussIDTextField.delegate = self;
self
is DiscussViewController and above code is inside DiscussViewController.m
Code works fine开发者_如何学Go but I don't like yellow bubbles showing on my screen while writing codes. If I want to get rid of this warning what should I do?
Warning : Assigning id from incompatible type 'DiscussViewController'.
The view controller (self) has to implement the UITextFieldDelegate
protocol. So your @interface
definition should look something like this:
@interface DiscussViewController : UIViewController <UITextViewDelegate>
And then of course in the implementation implement some of the delegated protocol methods.
In your .h file add UITextFieldDelegate between < > so that your view controller becomes text field delegate and then in the .m file implement delegate methods that you need.
@interface DiscussViewController : UIViewController <UITextFieldDelegate>
精彩评论