开发者

acceptConnectionFromPeer generates EXC_BAD_ACCESS

开发者 https://www.devze.com 2023-03-14 04:25 出处:网络
I try to setup a bluetooth connection between 2 devices (iPhone, iPad..). Everyting works fine until the client makes a connection request and the host crashes when calling acceptConnectionFromPeer (

I try to setup a bluetooth connection between 2 devices (iPhone, iPad..).

Everyting works fine until the client makes a connection request and the host crashes when calling acceptConnectionFromPeer (EXC_BAD_ACCESS)

-(void)session:(GKSession*)session didReceiveConnectionRequestFromPeer:(NSString*)peerID
{
  NSError* error=nil;
  [m_pSession acceptConnectionFromPeer:peerID error:&error];
}

m_pSession is valid.. trying to use

 NSString* displayName = [m_pSession displayNameForPeer:peerI开发者_如何学PythonD];

in the same place works fine

If anyone has an ideea what's wrong please let me know.


It looks like the session that is getting notified of the connection request isn't the same session that referenced by m_pSession. Trying changing to:

-(void)session:(GKSession*)session didReceiveConnectionRequestFromPeer:(NSString*)peerID
{
  NSError* error=nil;
  [session acceptConnectionFromPeer:peerID error:&error];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消