我在创建 vCard 时使用以下代码无济于事。它总是在 if block 中。有人可以看看我是否遗漏了什么吗?
xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
XMPPvCardTemp *myvCardTemp = [xmppvCardTempModule myvCardTemp];
if (!myvCardTemp)
{
NSXMLElement *vCardXML = [NSXMLElement elementWithName"vCard" xmlns"vcard-temp"];
XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
myvCardTemp = newvCardTemp;
}
[myvCardTemp setNickname"someNick"];
[myvCardTemp setMiddleName"somegender"];
[xmppvCardTempModule updateMyvCardTemp:myvCardTemp];
我已经尝试过了,但它仍然无法正常工作......被调用以获取 vcard 的函数总是返回 nil。
- (XMPPvCardTemp *)vCardTempForJIDXMPPJID *)jid shouldFetchBOOL)shouldFetch
此函数返回 nil 值。我有什么遗漏吗?
另一件事是它向日志发送错误:
错误保存 - Error Domain=NSCocoaErrorDomain Code=1570 "操作无法完成。(Cocoa 错误 1570。)
Best Answer-推荐答案 strong>
这就是我完成 vcard 编辑的方式
-(void)Editvcard
{
NSMutableDictionary *getdic = [[NSMutableDictionary alloc] init];
getdic = [[NSUserDefaults standardUserDefaults] valueForKey"UservCard"];
NSXMLElement *vCardXML = [NSXMLElement elementWithName"vCard" xmlns"vcard-temp"];
XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
// myvCardTemp = newvCardTemp;
//}
[newvCardTemp setGivenName:[getdic valueForKey"username"]];
[newvCardTemp setSortString:[getdic valueForKey"status"]];
[newvCardTemp setJid:[XMPPJID jidWithString:[[NSUserDefaults standardUserDefaults] stringForKey"kXMPPmyJID"]]];
[newvCardTemp setFormattedName:[getdic valueForKey:@"username"]];
[newvCardTemp setEmailIDnew:[getdic valueForKey:@"emailid"]];
NSString *img_name = [DatabaseAccess documentsPathForFileName:[getdic valueForKey:@"userimage"]];
NSData *pngData = [NSData dataWithContentsOfFile:img_name];
NSString *strThumb = @"";
if([[[UIDevice currentDevice] systemVersion] floatValue] >=7)
{
//Encode Image Data
strThumb = [Base64 encode:pngData];
//strMapThumb = [pngData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
}
else
{
//Encode Image Data
strThumb = [Base64 encode:pngData];
}
[newvCardTemp setPhoto:strThumb];
[xmppvCardTempModule updateMyvCardTemp:newvCardTemp];
}
希望对你有帮助....
关于ios - XMPPFramework - 创建 vCard,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/21397543/
|