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

发布于 2024-09-24 19:56:04 字数 997 浏览 1 评论 0原文

当我获取 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;

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

When I get a GKLocalPlayer or use loadPlayersForIdentifiers:identifiers withCompletionHandler: to get a list or individual GKPlayer aliases, the GKPlayer object when logged, looks something like this:

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))"
)

My question is, how do I get the status from this object, and what exactly is the type of this object? There is no "rid" or "status" property in the GKPlayer class, so when I do something like:

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

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

I get a "Request for member 'status' in something not a structure or union" error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

兮子 2024-10-01 19:56:04

苹果工程师的回答:

球员的状态不是
无障碍财产。这被改变了
在 4.1 beta 和 4.1 测试版之一中被注意到在
4.1 relnotes。

Answered by an Apple engineer:

The players' status is not an
accessible property. This was changed
in one of the 4.1 betas & is noted in
the 4.1 relnotes.

羁〃客ぐ 2024-10-01 19:56:04
NSString *desc = player.description;
NSRange range = [desc rangeOfString:@"status:"];
NSString *status = [[desc substringFromIndex:NSMaxRange(range)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *desc = player.description;
NSRange range = [desc rangeOfString:@"status:"];
NSString *status = [[desc substringFromIndex:NSMaxRange(range)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文