我有一些代码如下
#import <UIKit/UIKit.h>
@interface ViewMoreSettingController : UIViewController < UITableViewDelegate, UITableViewDataSource >
{}
@end
#import "ViewMoreSettingController.h"
@implementation ViewMoreSettingController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
//“MoreController.h”
#import <UIKit/UIKit.h>
@class ViewMoreSettingController;
@interface MoreController : UIViewController <UITableViewDataSource,UITableViewDelegate>{
ViewMoreSettingController *vViewMoreSettingController;
}
@property (retain,nonatomic) ViewMoreSettingController *vViewMoreSettingController;
@end
// ------------------------------ “MoreController.m”
#import "MoreController.h"
#import "ViewMoreSettingController.h"
@implementation MoreController
@synthesize vViewMoreSettingController;
-(void)doSomething
{
ViewMoreSettingController * temController ;
temController=[[ViewMoreSettingController alloc]initWithNibName:@"ViewMoreSetting" bundle:nil];//a: if remove this line it will compile successfully
[self.navigationController pushViewController:vViewMoreSettingController animated:YES];
[temController release];
}
它将报告
架构i386的未定义符号: “_OBJC_CLASS _ $ _ ViewMoreSettingController”,引自: MoreController.o中的objc-class-ref ld:找不到架构i386的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
如果我删除第一行:它将成功编译。
欢迎任何评论
答案 0 :(得分:2)
我们最近处于相同的情况。简单的解决方案是仅通过删除参考从项目中删除这些文件,然后再将这些文件添加到项目中,因为添加现有文件将解决问题。