我有以下的代码,但不能编译它,因为我有一个“类型名称需要说明符或限定词”错误”的(个体经营)。“类型名称需要说明符或限定词”错误
如何解决这个问题?我已经与原来的代码相比,它并没有差异,所以我不知道发生了什么事情。
#import "CurrentTimeViewController.h"
@implementation CurrentTimeViewController
{
// Call the superclass's designated initializer
self = [super initWithNibName:@"CurrentTimeViewController"
bundle:nil];
if (self) {
// Get the tab bar item
UITabBarItem *tbi = [self tabBarItem];
// Give it a label
[tbi setTitle:@"Time"];
}
return self;
}
下面是从镜像文件HynososViewController.h的代码,这是我剪切,粘贴和修改:
#import "HypnososViewController.h"
@implementation HypnososViewController
- (id) init
{
// Call the superclass's designated initializer
self = [super initWithNibName:nil
bundle:nil];
if (self) {
// Get the tab bar item
UITabBarItem *tbi = [self tabBarItem];
// Give it a label
[tbi setTitle:@"Hypnosis"];
}
return self;
}
- (id) initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
{
// Disregard parameters - nib name is an implementation detail
return [self init];
}
// This method gets called automatically when the view is created
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Loaded the view for HypnosisViewController");
// Set the background color of the view so we can see it
[[self view] setBackgroundColor:[UIColor orangeColor]];
}
@end
这里是CurrentTimeViewController.h的完整代码:
#import "CurrentTimeViewController.h"
@implementation CurrentTimeViewController
{
// Call the superclass's designated initializer
self = [super initWithNibName:@"CurrentTimeViewController"
bundle:nil];
if (self) {
// Get the tab bar item
UITabBarItem *tbi = [self tabBarItem];
// Give it a label
[tbi setTitle:@"Time"];
}
return self;
}
- (id) initWithNibName:(NSString *)nibName bundle:(NSBundle *)Bundle
{
// Disregard parameters - nib name is an implementation detail
return [self init];
}
// This method gets called automatically when the view is created
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Loaded the view for CurrentTimeViewController");
// Set the background color of the view so we can see it
[[self view] setBackgroundColor:[UIColor greenColor]];
}
@end
真的在这些代码行? – 2011-09-02 17:45:30
这是什么在xCode 4突出显示。有趣的是,在另一个视图控制器,除了笔尖和颜色的名称完全相同,没有这样的问题。 – pdenlinger