无法通过iVar访问UIViewController子类的title属性

时间:2013-04-04 11:09:48

标签: objective-c cocoa-touch uiviewcontroller kvc

在UIViewSubClass的初始化中,我使用iVar设置title属性(避免使用初始化程序中建议的setter):

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        _title = @"Pen";
    }
    return self;
}

我输入时没有显示错误,但是当我编译或分析时,我收到链接器错误:

Undefined symbols for architecture i386:
  "_OBJC_IVAR_$_UIViewController._title", referenced from:
      -[PenViewController initWithNibName:bundle:] in PenViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

发生了什么事?标题不符合KVC标准吗?

0 个答案:

没有答案