发送数据错误?
typedef struct _protocol1
{
int type;
CGPoint pos;
} Protocol1;
-(void)sendData {
NSError *error;
Protocol1 msg;
msg.pos = ccp(100,100);
msg.type = 1;
NSData *packet = [NSData dataWithBytes:&msg length:sizeof(Protocol1)];
[self.myMatch sendDataToAllPlayers: packet withDataMode: GKMatchSendDataReliable error:&error];
if (error != nil)
{
NSLog(@"error"]);
}
}
这是我项目中的一段代码。 我收到一个错误。但是,我不确定如何检索更多信息来帮助我调试。有人可以帮助我吗?
抱歉,我对 iOS 开发还很陌生……
使用 Cocos2d 开发游戏。
编辑
我正在使用模拟器和我的 iPhone 来测试这一点。我怀疑这就是问题所在,我已经让比赛正常进行了,一切......
typedef struct _protocol1
{
int type;
CGPoint pos;
} Protocol1;
-(void)sendData {
NSError *error;
Protocol1 msg;
msg.pos = ccp(100,100);
msg.type = 1;
NSData *packet = [NSData dataWithBytes:&msg length:sizeof(Protocol1)];
[self.myMatch sendDataToAllPlayers: packet withDataMode: GKMatchSendDataReliable error:&error];
if (error != nil)
{
NSLog(@"error"]);
}
}
That is a chunk of code from my project.
And I'm getting an error. However, I am unsure how to retrieve more information to help me debug. Can someone help me?
Sorry, I'm quite new with iOS development...
Using Cocos2d for a game.
EDIT
I am using the Simulator and my iPhone to test this. I doubt that is the problem, I already got the match working and everything...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要打印出您的错误,请尝试此操作!
如果遇到问题,只需单击 XCode4 中的 NSError 即可。
然后查看右侧的列,然后单击以获取文档。
(或者只需在 Xcode 文档中搜索“NSError”。)
调出“NSError Class Reference”。这很简单。
请务必查看给出的各种示例代码。
例如,向下滚动到“localizedDescription”并查看三个示例代码。 (“LazyTableImages、SeismicXML、URLCache”)
您可以下载并查看示例项目。如果遇到问题,搜索“localizedDescription”,您会看到示例!
如果你教一个人钓鱼......哈哈,玩得开心。
To print out your error, try this!
if you have trouble, just click on NSError in your XCode4.
Then look at the right column, and click to get to the documentation.
(Or just search "NSError" in the Xcode documentation.)
Bring up "NSError Class Reference". It is very simple.
Be sure to look at the VARIOUS EXAMPLE CODE given.
For example scroll down to "localizedDescription" ad see the three sample codes. ("LazyTableImages, SeismicXML, URLCache")
You can download and look at the example projects. Search on "localizedDescription" and you'll see examples, if you're having trouble!
If you teach a man to fish ... Lol have fun.