错误:'GKPeerPickerController之前的预期说明符限定符列表

时间:2009-06-26 16:33:54

标签: objective-c bluetooth header-files p2p

我不断收到此消息(标题中)。如果你想看看我在做什么,只需快速查看我的代码。我刚刚开始实施Peer Picker,所以我还没完成。我在第一部分需要一些建议/帮助。错误显示在两个#import语句之间的.m文件中,这意味着它必须是一些错误的方式,我在头文件中使用了GKPeerPickerController。

Bluetooth_Ad_Hoc_NetworkAppDelegate.h

#import <UIKit/UIKit.h>

@class Bluetooth_Ad_Hoc_NetworkViewController;

@interface Bluetooth_Ad_Hoc_NetworkAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    Bluetooth_Ad_Hoc_NetworkViewController *viewController;

    GKPeerPickerController *picker;
    GKSession *session;
    IBOutlet UILabel *status;
    NSData *data;
}

@property(nonatomic, retain)IBOutlet UILabel *status;
@property(nonatomic, retain)GKPeerPickerController *picker;
@property(nonatomic, retain)GKSession *session;
@property(nonatomic, retain)IBOutlet UIWindow *window;
@property(nonatomic, retain)IBOutlet Bluetooth_Ad_Hoc_NetworkViewController *viewController;


@end

Bluetooth_Ad_Hoc_NetworkAppDelegate.m

#import "Bluetooth_Ad_Hoc_NetworkAppDelegate.h"
#import "Bluetooth_Ad_Hoc_NetworkViewController.h"

@implementation Bluetooth_Ad_Hoc_NetworkAppDelegate

@synthesize status;
@synthesize picker;
@synthesize session;
@synthesize window;
@synthesize viewController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    // allocate and initialize data
    data = [[NSData alloc] initWithBytes:&status length:sizeof(status)];

    // Allocate and setup peer picker controller
    picker = [[GKPeerPickerController alloc] init];
    picker.delegate = self;
    picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
    [picker show];

}


- (void)dealloc {
    [status release];
    [viewController release];
    [window release];
    [super dealloc];
}


@end

1 个答案:

答案 0 :(得分:3)

您是否已将此语句包含在头文件中?

#import <GameKit/GameKit.h>

此外,您还需要包含GameKit框架。

相关问题