我使用以下代码实例化视图会话并传递对象“SenderPlayerViewController”:
- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState: GKPeerConnectionState)state {
switch (state) {
case GKPeerStateConnected:
NSLog(@"Connected Central");
if ([settings.playerType isEqualToString:@"SENDER"]){
SenderPlayerViewController *myViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:NULL] instantiateViewControllerWithIdentifier:@"SenderPlayerViewController"];
[self.navigationController pushViewController:myViewController animated:YES];
myViewController.currentSession=session;
}
break;
case GKPeerStateDisconnected:
NSLog(@"Disconnected Central");
self.currentSession = nil;
break;
}
}视图SenderPlayerViewController的头文件为:
@interface CentralViewController : UIViewController {
Settings *settings;}
@property (nonatomic, copy) GKSession *currentSession;
@end 当执行代码时,我得到以下错误:
[GKSession copyWithZone:]: unrecognized selector sent to instance 0x9661200你能帮帮我吗!
提前感谢!
发布于 2012-05-01 03:45:29
@property (nonatomic, copy) GKSession *currentSession;是错误的。GKSession不是一个可复制的对象。因此,您应该通过保留以下内容来获取对它的引用:
@property (nonatomic, retain) GKSession *currentSession;https://stackoverflow.com/questions/10389573
复制相似问题