سؤال

So I have sending and receiving data in GameCenter on my iphone working well, but when you receive data you get 'data' from the method. How do you know whether this is for example a score or health points?

How do you differentiate what data is received?

Thanks.

هل كانت مفيدة؟

المحلول

As explained by Apple's docs...

'Your message format should include a way to differentiate between different kinds of messages. For example, you might create an enumerated type that identifies different kinds of messages. The first bytes in every message would start with this enumerated type.'

نصائح أخرى

Look at SessionManager.m in the GKRocket example in the docs. Especially the implementations of

-(void) sendPacket:(NSData*)data ofType:(PacketType)type

and

- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top