如何从Game Center获得GKPlayer的状态?

时间:2010-09-23 17:56:06

标签: objective-c ios4 gamekit game-center

当我获得GKLocalPlayer或使用loadPlayersForIdentifiers:identifiers withCompletionHandler:获取列表或单个GKPlayer别名时,GKPlayer对象在记录时看起来像这样:

2010-09-23 10:39:01.759 Cee-lo[76500:207] Players loaded by identity: (
    "<GKPlayer 0x84125a0>(playerID: G:1234567890, alias: typeonetester1, status: Adding test friends., rid:(null))",
    "<GKPlayer 0x8412530>(playerID: G:1234567890, alias: typeonetester2, status: Adding Game Center to app, rid:(null))"
)

我的问题是,如何从此对象获取status,以及该对象的类型究竟是什么? GKPlayer类中没有“rid”或“status”属性,因此当我执行以下操作时:

GKPlayer *player = [self.friends objectAtIndex:row];

cell.nameLabel.text = player.alias;
cell.statusLabel.text = player.status;

我收到“请求成员'状态',而不是结构或联合”错误。

2 个答案:

答案 0 :(得分:2)

Apple工程师回答:

  

球员的状态不是   无障碍财产。这改变了   在其中一个4.1测试版和注意到   4.1重新注意。

答案 1 :(得分:1)

NSString *desc = player.description;
NSRange range = [desc rangeOfString:@"status:"];
NSString *status = [[desc substringFromIndex:NSMaxRange(range)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];