I want to create a class for Mac OS and iOS app. Unfortunately, I cannot use NSColor for iOS and UIColor for Mac OS.
In fact, I have the following code:
#if os(iOS) func myFunc(color: UIColor?) { self.myFuncX(color) } #elseif os(OSX) func myFunc(color: NSColor?) { self.myFuncX(color) } #endif private func myFuncX(color: AnyObject?) { #if os(iOS) myColor = color as! UIColor #elseif os(OSX) myColor = color as! NSColor #endif }
Is there a better way?
source share