views:

271

answers:

1

I have a CGImageRef variable and a CGRect (so no pointers) and I need to add it to an NSDictionary. Like an NSArray, NSDictionary-s only accept pointers. How can you add an CGImageRef or an CGRect anyway?

+2  A: 

CGImageRef is already a pointer, but it's not (AFAIK) a pointer to a valid Cocoa object. You can turn a CGImage into a Cocoa NSBitmapImageRep with [[NSBitmapImageRep alloc] initWithCGImage:someimageref]. And NSValue is there to wrap primitive types like CGRect.

Chuck