Obj C - UITextViewDelegate不兼容类型警告

rd4*_*d42 0 objective-c uitextview

带有journalComment.delegate = self的行警告:从不兼容类型'JournalEntryViewController*'分配给'id'

journalComment是一个textView.

我不确定警告是什么,它应该只是说 - 警告:"键盘上的新手,去参加一些obj c课程."

感谢您的任何帮助.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        // Hide keyboard when done key is pressed

        // define the area and location for the UITextView
        CGRect tfFrame = CGRectMake(0, 0, 320, 460);
        journalComment = [[UITextView alloc] initWithFrame:tfFrame];
        // make sure that it is editable
        journalComment.editable = YES;

        // add the controller as the delegate
        journalComment.delegate = self;

    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

Eik*_*iko 10

您的类必须符合UITextViewDelegate协议,因此在.h文件中使其看起来像

@interface JournalEntryViewController : NSViewController <UITextViewDelegate>
{

...

}
Run Code Online (Sandbox Code Playgroud)

然后编译器将知道您的类符合该协议.当然,您仍然需要实现所需的方法.