gpt4 book ai didi

objective-c - copyWithZone 错误

转载 作者:行者123 更新时间:2023-12-02 08:48:42 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/10389573/

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