这里我能够从核心数据中获取文本消息,但无法在数据库中找到任何已接收的图像url或NSData 任何人都可以帮我解决如何从XMPP inbuild数据库中获取图像 这是我从核心数据中获取文本消息的代码,谢谢
func fetchMessageConversation() {
// Initialize Fetch Request
let fetchRequest = NSFetchRequest<NSFetchRequestResult>()
let managedObjectContext = self.appDelegate.xmppMessageArchivingCoreDataStorage.mainThreadManagedObjectContext
// Create Entity Description
let entityDescription = NSEntityDescription.entity(forEntityName: "XMPPMessageArchiving_Message_CoreDataObject", in: managedObjectContext!)
// Create predicate //
let resultPredicate = NSPredicate(format: "bareJidStr like %@", bareJidStr)
fetchRequest.predicate = resultPredicate
// Configure Fetch Request
fetchRequest.entity = entityDescription
var resultAry : NSArray!
do {
resultAry = try managedObjectContext?.fetch(fetchRequest) as NSArray!
//print(result as Any)
for i in 0..<resultAry.count {
let messageDetails = resultAry.object(at: i) as? XMPPMessageArchiving_Message_CoreDataObject
if (messageDetails?.body != nil) {
let composeMsgDic = NSMutableDictionary ()
composeMsgDic.setValue(messageDetails?.isOutgoing, forKey: "isOutgoing")
composeMsgDic.setValue(messageDetails?.timestamp, forKey: "time")
composeMsgDic.setValue(messageDetails?.body, forKey: "message")
composeMsgDic.setValue(messageDetails?.message.elementID(), forKey: "messageID")
MsgconversationAry.add(composeMsgDic)
}
}
} catch {
let fetchError = error as NSError
print(fetchError)
}
}