CocoaDev

Edit AllPages

NSImageRep is a concrete image representation for use by NSImage or directly.

Among other things, it can be subclassed to easily make NSImage support custom image types. The online documentation is a bit inaccurate. Here’s an example of how you can implement your own NSImageRep:

@interface CustomImageRep : NSImageRep { CGImageRef image; } @end

@implementation CustomImageRep

To make it work automatically when calling [[NSImage alloc] initWith*], you have to register it. Add this to some class that gets loaded early:

NSBitmapImageRep might work too. But I had some trouble with it. NSImageRep is easy enough to implement and works like a charm.