XMPPFramework:尝试更新 VCard 上的昵称 [英] XMPPFramework: Trying to update nickname on VCard
问题描述
这个问题就像它的标题一样简单:我正在尝试更新他的 VCard 上的用户昵称,但我不能.我正在使用此代码:
This question is as simple as its title says: I'm trying to update a user nickname on his VCard but I cannot. I'm using this code:
dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
dispatch_async(queue, ^{
XMPPvCardTemp *myVcardTemp = [[[self appDelegate] xmppvCardTempModule] myvCardTemp];
[myVcardTemp setNickname:@"a_nickname"];
[[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp:myVcardTemp];
});
我无法想象为什么这段代码不想在同一段代码中工作,但更新照片却像魅力一样工作:
I cannot imagine why this piece of code don't want to work while the same piece, but updating photo, is working like a charm:
NSData *imageData = UIImagePNGRepresentation(anImage);
dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
dispatch_async(queue, ^{
XMPPvCardTemp *myVcardTemp = [[[self appDelegate] xmppvCardTempModule] myvCardTemp];
[myVcardTemp setPhoto:imageData];
[[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp:myVcardTemp];
});
任何帮助将不胜感激...这让我发疯
Any help would be appreciated... this is driving me crazy
注意:我使用 OpenFire 作为 XMPP 服务器
NOTES: I'm using OpenFire as XMPP server
这是当我尝试更新昵称时服务器返回给我的节
And this is the stanza the server returns me when I'm trying to update the nickname
RECV: <iq xmlns="jabber:client" type="result" from="7db55e68-cb18-4826-befd-0eb9269637aa@000.000.000.000" to="7db55e68-cb18-4826-befd-0eb9269637aa@000.000.000.000/2cfc4f88"><chat_jorges xmlns="vcard-temp"><NICKNAME>chat_jorges</NICKNAME></chat_jorges></iq>
(我将服务器的 ip 更改为 000.000.000.000)
(I changed my server's ip for 000.000.000.000)
推荐答案
我完全错了,不要读这个
EDIT : I WAS TOTALLY WRONG DON'T READ THIS
其实我在看XMPP的源码的时候,就想知道它是怎么设置值的.在 XMPPvCardTempBase.h 中:
Actually when I read the source code of XMPP, I wonder how it could set a value. In XMPPvCardTempBase.h :
#define XMPP_VCARD_SET_STRING_CHILD(Value, Name) NSXMLElement *elem = [self elementForName:(Name)];
//it looks like a get and not a set??
在 XMPPvCardTemp.m 中:
And in XMPPvCardTemp.m :
- (void)setNickname:(NSString *)nick {
XMPP_VCARD_SET_STRING_CHILD(nick, @"NICKNAME");
}
也许某处有 KVC 之类的东西......你能在源代码中试试这个吗:
Maybe there is something as KVC somewhere... Can you try this in the source code:
- (void)setNickname:(NSString *)nick {
XMPP_VCARD_SET_STRING_CHILD(nick, @"NICKNAME") = nick ;
}
这篇关于XMPPFramework:尝试更新 VCard 上的昵称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!