在 UIViewSubClass 的初始化程序中,我使用 iVar 设置标题属性(避免初始化程序中推荐的设置器):
- (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 吗?