How can I store a UIImage in an NSDictionary?

Viewed 16989

How can I store a UIImage in an NSDictionary?

6 Answers

Yes you can:

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1];
UIImage *img = ...;
[dict setObject:img forKey:@"aKeyForYourImage"];

UIImage *imgAgain = [dict objectForKey:@"aKeyForYourImage"];

[dictionary setObject:yourImage forKey:@"whatever key you want"];

Untested ;-)

[dict setObject:image forKey:@"ImageToStore"];

Related