How can I store a UIImage in an NSDictionary?

RexOnRoids picture RexOnRoids · Feb 2, 2010 · Viewed 16.6k times · Source

How can I store a UIImage in an NSDictionary?

Answer

Felix Lamouroux picture Felix Lamouroux · Feb 2, 2010

Yes you can:

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

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