【发布时间】:2011-10-21 02:12:57
【问题描述】:
我已经浏览了无数关于这个错误的帖子:
Undefined symbols:
"_OBJC_CLASS_$_BoxView", referenced from:
objc-class-ref-to-BoxView in ViewMovingViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
BoxView 是UIView 的子类,并包含UIKit 框架。 BoxView.h 已导入 ViewController。
ViewController 包含以下代码:
-(void) addBoxViewAtLocation:(CGPoint)point {
CGRect rect;
rect.origin.x = point.x;
rect.origin.y = point.y;
rect.size.width = 80;
rect.size.width = 40;
BoxView *newView = [[BoxView alloc] initWithFrame:rect];
newView.backgroundColor = [UIColor yellowColor];
[mainView addSubview:newView];
}
而BoxView 包含此代码:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// no further initialization
}
return self;
}
这是导致错误的行,来自上面的代码:
BoxView *newView = [[BoxView alloc] initWithFrame:rect];
当我在该行中将 BoxView 更改为 UIView 时,错误消失了。有谁知道我需要在这里改变什么?我浏览了很多关于此的帖子,但大多数答案都说它与链接相关,但我尝试勾选和取消勾选某些框但没有成功。我想知道错误是否在我的代码中?任何建议将不胜感激!
【问题讨论】:
标签: objective-c ios xcode linker