3

当我获取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类中没有“摆脱”或“状态”属性,所以当我执行以下操作时:

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

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

我收到“在非结构或联合的情况下请求成员‘状态’”错误。

4

2 回答 2

2

苹果工程师回答:

玩家的状态不是可访问的属性。这在 4.1 测试版之一中进行了更改,并在 4.1 相关注释中注明。

于 2010-09-23T18:33:20.257 回答
1
NSString *desc = player.description;
NSRange range = [desc rangeOfString:@"status:"];
NSString *status = [[desc substringFromIndex:NSMaxRange(range)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
于 2013-01-22T11:37:16.823 回答