[swift-evolution] Pitch: Expose enum properties backed by bridgeable types to Objective-C

Charlie Monroe charlie at charliemonroe.net
Thu Dec 15 00:30:15 CST 2016


> On Dec 15, 2016, at 7:28 AM, Charles Srstka via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Dec 15, 2016, at 12:16 AM, Derrick Ho <wh1pch81n at gmail.com <mailto:wh1pch81n at gmail.com>> wrote:
>> 
>> You can currently access swift enums from objective c provided that it is marked @objc and inherits from Int.
> 
> Not when I try it:
> 
> enum MyEnum: Int {

The @objc annotation needs to be here.

@objc enum MyEnum: Int { ... }

You can then freely do even this:

@NSManaged var enumValue: MyEnum

and it works just fine with CoreData...

>     case foo = 0
>     case bar = 1
> }
>     
> @objc var myEnum: MyEnum = .foo // Property cannot be marked @objc because its type cannot be represented in Objective-C
> 
> Charles
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161215/6344ab3a/attachment.html>


More information about the swift-evolution mailing list