0

I have created an extension for UIColor in swift to add custom colors. The colors I have grouped together in their own namespace for which I have used enums with no cases. Here is the class:

extension UIColor {
    public enum FirstGroup {
        static var salmonColor: UIColor {
            return UIColor(red: 255.0 / 255.0, green: 102.0 / 255.0, blue: 102.0 / 255.0, alpha: 1.0)
        }
    }

    public enum SecondGroup {
        static var strawberryColor: UIColor {
            return UIColor(red: 255.0 / 255.0, green: 0.0 / 255.0, blue: 128.0 / 255.0, alpha: 1.0)
        }
    }
}

I am able to call this in my swift class like UIColor.FirstGroup.salmonColor

Now, I would like to use this extension in my Objective-C classes too. How can I do that?

iOSer
  • 235
  • 2
  • 14
  • Note that you can use only Int-based enums in Objective-C – Cristik Sep 08 '16 at 03:40
  • OK, even if I change the enums to Int how do I access them in objC? – iOSer Sep 08 '16 at 04:04
  • Possible duplicate of http://stackoverflow.com/questions/30480338/how-to-make-a-swift-string-enum-available-in-objective-c. – Martin R Sep 08 '16 at 04:13
  • Is it a full extension's code? Why don't you have some items inside your enums, only a static var? – Roman Podymov Sep 08 '16 at 07:54
  • @RomanPodymov It is just an extension to add custom colors. The enums are just to create namespace. – iOSer Sep 08 '16 at 16:59
  • @MartinR I did look at that question. I was wondering if there is a different way than to create a wrapper class for enums as I don't have any cases in these enums. – iOSer Sep 08 '16 at 17:00

0 Answers0