错误:@synthesize

iPh*_*one 4 iphone objective-c

在我的AppDelegate.h文件中,我编写了以下代码

@interface iBountyHunterAppDelegate : NSObject <UIApplicationDelegate> {
    UITabBarController *tabcontroller;

}
@property (nonatomic,retain) IBOutlet UITabBarController *tabcontroller;
Run Code Online (Sandbox Code Playgroud)

在AppDelegate.h文件中我合成它.

@synthesize tabcontroller;
Run Code Online (Sandbox Code Playgroud)

但是在@synthesize行我得到一个错误,并且msg是:"遗产属性执行声明的上下文"

任何人都可以告诉我如何解决它?

Jer*_*myP 6

我怀疑你把@synthesize@implementation 放在了外面.看起来应该是这样的

//  iBountyHunterAppDelegate.m

#import "iBountyHunterAppDelegate.h"

@implementation iBountyHunterAppDelegate

@synthesize tabcontroller; // note that this is between @implementation and @end

// other stuff

@end
Run Code Online (Sandbox Code Playgroud)


Mac*_*wia 5

"在AppDelegate.h文件中,我合成了它." 可能它只是拼写错误但它必须在.m文件中:P