我有一些代码如下
#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类refld:找不到体系结构i386的符号clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
如果我删除行a:它将成功编译。
欢迎任何评论
我们最近也遇到了同样的情况。简单的解决方案是仅通过删除引用从项目中删除这些文件,然后再次将这些文件添加到项目中,因为添加现有文件将解决问题。