[英]Easiest way to store NSCache full of NSImages
What is the simplest way to persistently store a NSCache
filled with NSImage
s? 持久存储充满
NSImage
的NSCache
的最简单方法是什么? I'm not looking for Core Data, which seems like overkill for just storing a dictionary with images. 我不是在寻找Core Data,因为仅将字典与图像一起存储似乎显得有些过时。
If all you have is a set of pictures, I'd simply get a path from the user and use NSImage's TIFFRepresentation
to get instances of NSData for each picture, which can then be written to the path using NSFileManager and NSFileHandle. 如果您只拥有一组图片,那么我只需从用户那里获取路径,然后使用NSImage的
TIFFRepresentation
来获取每张图片的NSData实例,然后可以使用NSFileManager和NSFileHandle将它们写入路径。
If you have info accompanying the images, like tags, I'd put that, along with identifying titles for the images, in an array of dictionaries. 如果您有伴随图像的信息(例如标签),我会将其与识别图像标题一起放在字典数组中。 Then you can use NSArray's
writeToFile:atomically:
method to write out a plist. 然后,您可以使用NSArray的
writeToFile:atomically:
方法写出一个plist。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.