gpt4 book ai didi

objective-c - copyWithZone-无法识别的选择器发送到实例

转载 作者:太空狗 更新时间:2023-10-30 03:37:33 24 4
gpt4 key购买 nike

我正在使用以下代码来实例化 View SenderPlayerViewController 并传递对象“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;
}
}

View SenderPlayerViewController的头文件是:

@interface CentralViewController : UIViewController {
Settings *settings;}
@property (nonatomic, copy) GKSession *currentSession;

@end

执行代码时出现以下错误:

[GKSession copyWithZone:]: unrecognized selector sent to instance 0x9661200

这里需要更多帮助....

最佳答案

属性:

@property (nonatomic, copy) GKSession *currentSession;

错了。 GKSession 不是可复制的对象。所以你应该通过保留来获取对它的引用:

@property (nonatomic, retain) GKSession *currentSession;

关于objective-c - copyWithZone-无法识别的选择器发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15068154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com