Search code examples
xcodeosx-mavericks

What should I use to display a jpg file in an OS X app? UIImage, CGImage or Image Kit?


I am confused by the availability of two set of widgets: NSImageView and IKImageView ('Image Kit Image View').

My goal is to load some jpg files from disk and display them. No editing is necessary.

Which widget or framework is more appropriate?

And I suppose UIImage is totally not applicable here because it is for iOS platform.


Solution

  • Use NSImageView for most normal cases. IKImageView is for specialized cases, including allowing editing operations.

    NSImage is the model object that you would use normally. CGImage is lower level and is sometimes used, but I would say only when a) some API you otherwise need to use naturally works with CGImage, or b) CGImage provides a capability not available from NSImage, NSImageRep or its subclasses (e.g. NSBitmapImageRep).

    Yes, UIImage is not applicable for OS X.