1

嗨我正在使用gamekit连接两个IOS设备以在它们之间传输数据,下面是我在这里使用的代码

.h 

@property (nonatomic,strong)GKSession *sessionObj;
...

.m

...
GKPeerPickerController *connectionPicker = [[GKPeerPickerController alloc] init];
connectionPicker.delegate = self;

//NOTE - GKPeerPickerConnectionTypeNearby is for Bluetooth connection, you can do the same thing over Wi-Fi with different type of connection
connectionPicker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
[connectionPicker show];

sessionObj = [[GKSession alloc] initWithSessionID:@"com.myapp.connect" displayName:nil sessionMode:GKSessionModePeer];
sessionObj.delegate = self;

所以当我运行应用程序时,它会转到 GKPeerPickerControllerDelegate

-(GKSession *)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type{
 return sessionObj;

并且一旦它从这个委托方法返回它就会抛出一个错误,它说

*** Terminating app due to uncaught exception 'GKInvalidArgumentException', reason: 'A vaild GKSession object with a GKSessionModePeer mode must be supplied, or to create a default GKSession object return 'nil' in the implementation of -peerPickerController:sessionForConnectionType:. Supplied object was: (null description) with session mode: 0'
*** First throw call stack:
(0x1335052 0x1155d0a 0x12dda78 0x12dd9e9 0x665e0 0x65798 0x64e9a 0x64e13 0x5d15cb 0x64cf7 0x63237 0xb781 0xb438 0x5099d6 0x50a8a6 0x519743 0x51a1f8 0x50daa9 0x1d67fa9 0x13091c5 0x126e022 0x126c90a 0x126bdb4 0x126bccb 0x50a2a7 0x50ba9b 0xc12d 0x75f5 0x1)
terminate called throwing an exception(lldb) 

你能告诉我这里有什么问题吗?

4

0 回答 0