问题
I was able to create and update a vCard using this code
let xmppvCardStorage = XMPPvCardCoreDataStorage.sharedInstance()
let xmppvCardTempModule = XMPPvCardTempModule.init(vCardStorage:xmppvCardStorage!)
xmppvCardTempModule.activate(self.stream)
xmppvCardTempModule.addDelegate(self, delegateQueue: DispatchQueue.main)
let vCard = DDXMLElement(name: "vCard", xmlns: "vcard-temp")
let vCardTemp = XMPPvCardTemp.vCardTemp(from: vCard)
vCardTemp.nickname = "john"
vCardTemp.jid = XMPPJID(string: "john123@www.example.com")
Also I was able to fetch that vCard using the following code:
let xmppvCardStorage = XMPPvCardCoreDataStorage.sharedInstance()
let xmppvCardTempModule = XMPPvCardTempModule.init(vCardStorage: xmppvCardStorage!)
xmppvCardTempModule.activate(self.stream)
let jID = XMPPJID(string: "john@www.example.com")
xmppvCardTempModule.addDelegate(self,delegateQueue:DispatchQueue.main)
xmppvCardTempModule.fetchvCardTemp(for: jID!, ignoreStorage:false)
As you can see I am fetching the vCard from my server. This is done by setting ignoreStorage
to false
My question is does the XMPPFrameWork support a way to store the retrieved vCards in CoreData such that I don't have to retrieve it every time
回答1:
fetchvCardTemp
simply fetches the vCardTemp for the given JID if it is not in the storage.when you set ignoreStorage
to false you are saying that i don't want to use storage and i want to fetch it via the XMPPStream.
you should use just xmppvCardStorage and one of it's function called vCardTempForJID
and simply pass your favorite jID and it will return it to you
来源:https://stackoverflow.com/questions/51797335/saving-fetched-xmppframework-vcards-into-coredata-in-swift4