方法“session:peer:didChangeState”

发布于 2024-10-19 22:14:50 字数 989 浏览 0 评论 0原文

我读了那篇文章:“ http://www.devx.com/wireless /Article/43502/0/page/1 "

我想在我的应用程序中集成蓝牙。我有一个问题。我想连接 2 个设备,并且想知道两个设备上是否都调用了函数“session:peer:didChangeState”。在我看来,我认为它在两种设备上都被调用。

我想知道是否在两个设备上调用了方法 session:peer:didChangeState 。

我想通过蓝牙发送一个结构: 我的结构如下:

typedef struct Package
{
    tip_Comunicare_Enum type;
    union mesaj_Comunicare
    {
        Msg_Cerere_Struct msg_Cerere;
        Msg_Raspuns_Struct msg_Raspuns;
        Msg_Initializare msg_Initializare;
    }mesaj_Comunicare;
}
Package ;

我的序列化器看起来像这样:

-(void) SendData:(Package *) pachet
{
NSLog(@"Send DATA pachet");

printf("%d\n",sizeof(*pachet));

NSData * myData = [[NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)] autorelease]; 
[self mySendDataToPeers:myData];
}

如果我这样使用它就不起作用,我会给出 SIGKILL 或类似的东西。

感谢和我一起度过的时光:)

I read that article : " http://www.devx.com/wireless/Article/43502/0/page/1 "

I want to integrate in my application Bluetooth. I had a problem. I want to connect 2 devices and i want to know if the function "session:peer:didChangeState" is called on the both device. In my opinion i think it is called on the both devices.

I want to know if the method session:peer:didChangeState is called on the both devices .

I want to send via bluetooth a structure:
My structure is following :

typedef struct Package
{
    tip_Comunicare_Enum type;
    union mesaj_Comunicare
    {
        Msg_Cerere_Struct msg_Cerere;
        Msg_Raspuns_Struct msg_Raspuns;
        Msg_Initializare msg_Initializare;
    }mesaj_Comunicare;
}
Package ;

My serializer looks like that :

-(void) SendData:(Package *) pachet
{
NSLog(@"Send DATA pachet");

printf("%d\n",sizeof(*pachet));

NSData * myData = [[NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)] autorelease]; 
[self mySendDataToPeers:myData];
}

If i use like that it is doesn't work and i give SIGKILL or something like that.

Thant for the time spent with me :)

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

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

发布评论

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

评论(1

时光暖心i 2024-10-26 22:14:50
NSData * myData = [[NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)] autorelease]; 

myData 已经自动发布。你必须这样写:

NSData * myData = [NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)]; 

记住:自动释放消息被发送的次数与被调用的次数一样多。

NSData * myData = [[NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)] autorelease]; 

myData is already autoreleased. You have to write:

NSData * myData = [NSData dataWithBytes:pachet 
                                  length:sizeof(*pachet)]; 

Remember: autorelease message is sent as many times as it is called.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文