What should I pass as parameter to a method expecting a NSError**?
-
06-07-2019 - |
Question
I have been creating a peer to peer connection for a new game, that does not use the peer picker. I am however dumbstruck as what to put in here:
- (void)session:(GKSession *)session didReceiveConnectionRequestFromPeer:(NSString *)peerID {
NSLog(@"I GOTS A CONNECTION REQUEST");
if(connected == YES) {
//deny all requests
}
else if(connected == NO) {
[session acceptConnectionFromPeer:peerID error:???];
}
}
What should I put where the question marks are? The documentation says NSError **.
Solution
It's a pointer to an NSError*, so :
NSError* error=nil;
[session acceptConnectionFromPeer:peerID error:&error];
OTHER TIPS
If there is no error set error
to nil.
error
is a means of conveying to the rest of your application why the connection is not beeing established.
In you example roll your own NSError stating that your application is not accepting connections because it is already connected to a client.
See the iPhone Dev Center documentation for NSError to see how to populate it.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow