houbysoft
houbysoft

Reputation: 33430

Easiest way to store NSCache full of NSImages

What is the simplest way to persistently store a NSCache filled with NSImages? I'm not looking for Core Data, which seems like overkill for just storing a dictionary with images.

Upvotes: 2

Views: 551

Answers (1)

Wienke
Wienke

Reputation: 3733

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.

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.

Upvotes: 1

Related Questions