In Objective-C we have a category on both UIColor and NSColor where the code itself is identical - 100%. The only difference is the return types. So we have a #define at the top - if we're on iOS "#define PIColor UIColor" and on OS X we "#define PIColor NSColor".
I can't seem to get this to work in Swift and it may not be possible, but I've only been using Swift for a week - so asking here. Maybe there is a better way to do this (protocol extensions maybe?). I am using Swift 2.
I was disappointed that this didn't work:
#if os(iOS)
extension UIColor {
#elseif os(OSX)
extension NSColor {
#endif
func stringFromColor() -> String {
}
}I can just keep our ObjC version for now…but this seems like there should be a way to do this in Swift.