我做应用程序swift 2.3
并Realm database
获取Kingfisher framework
图像。我从服务器获取图像JSON
let urls = NSURL(fileURLWithPath: newsRealm.newsImage)
let prefetcher = ImagePrefetcher(urls: [urls], optionsInfo: nil, progressBlock: nil, completionHandler: {
(skippedResources, failedResources, completedResources) -> () in
print("These resources are prefetched: \(completedResources)")
})
prefetcher.start()
它是成功的,但是图像Realm database
是NSData
,如何将接收到的数据写入Kingfisher
到Realm
NSData
领域类:
class News: Object {
dynamic var newsImage: String = ""
dynamic var images: NSData?
}
你好!我无法将图像写入我的数据库:
let urls = NSURL(fileURLWithPath: newsRealm.newsImage)
let prefetcher = ImagePrefetcher(urls: [urls], optionsInfo: nil, progressBlock: nil, completionHandler:
{(skippedResources, failedResources, completedResources) -> () in
print("These resources are prefetched: (completedResources.description)")
let images: [NSData] = completedResources
newsRealm.images = images