I am using the following code to instantiate the view SenderPlayerViewController and pass the object “session” :
- (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;
}
}
The header file of view SenderPlayerViewController is :
@interface CentralViewController : UIViewController {
Settings *settings;}
@property (nonatomic, copy) GKSession *currentSession;
@end
When the code is executed i get the following error :
[GKSession copyWithZone:]: unrecognized selector sent to instance 0x9661200
Can you please help!
Thanks in advance!
is wrong. GKSession is not a copiable object. So you should just grab a reference to it by retaining: