在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标准吗?