errore: elenco specificatori-qualificatore-attesi prima di 'GKPeerPickerController
-
20-08-2019 - |
Domanda
Continuo a ricevere questo messaggio (nel titolo). Dai un'occhiata al mio codice se vuoi vedere cosa sto facendo. Ho appena iniziato a implementare Peer Picker, quindi non ho ancora finito. Ho solo bisogno di un consiglio / aiuto nella prima parte. L'errore viene visualizzato nel file .m tra le due istruzioni #import, il che significa che deve essere stato un modo sbagliato di usare GKPeerPickerController nel file di intestazione.
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
Soluzione
Hai incluso questa affermazione nel file di intestazione?
#import <GameKit/GameKit.h>
Inoltre devi includere il framework GameKit.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow