nsdictionary で nsnumber を送信するために gamekit を使用しています。ディクショナリを NSlog すると番号は問題ありませんが、NSNumber を取得しようとすると、常に (null) になります。
NSMutableDictionary *dict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSNumber *receivedHostNum = (NSNumber*)[dict objectForKey:@"h"];
if (gameStarted == NO){
NSLog(@"%@",dict);
NSLog(@"My Num:%i",[hostNum intValue]);
NSLog(@"%@",receivedHostNum);
NSLog(@"Recieved Num:%i",[receivedHostNum intValue]);
if ([hostNum intValue]>[receivedHostNum intValue])
NSLog(@"You are host");
else
NSLog(@"You are client");
}
これはログです:
2012-08-21 14:34:06.067 PeerPicker[6667:c07] {
"-589267889" = h;
}
2012-08-21 14:34:06.068 PeerPicker[6667:c07] My Num:-2142897577
2012-08-21 14:34:06.068 PeerPicker[6667:c07] (null)
2012-08-21 14:34:06.069 PeerPicker[6667:c07] Recieved Num:0
2012-08-21 14:34:06.069 PeerPicker[6667:c07] You are client