Search code examples
iosmacosporting

Implementing UIView on top of NSView for porting from iOS to Mac OSX


I'd like to port my app to Mac OSx. in that vein, I'd like to create a class called "UIView" as an extension of NSView .. is this doable? Other than the coordinate system, is there anything I need to be worried about?

I assume CALayer and CoreAnimation are mostly the same. Other classes are UIImage and UIImageView, UIButton, etc.

Has anyone attempted this yet?


Solution

  • I second MCannon’s advice: you preprocessor macros, or abstract your classes behind an opaque class object, but I strongly advise against creating a new UIView class inheriting from NSView on Mac.