Adding Swift-bridging hints in Obj-C headers?
Adding Swift-bridging hints in Obj-C headers?
- Subject: Adding Swift-bridging hints in Obj-C headers?
- From: Jens Alfke <email@hidden>
- Date: Tue, 16 Sep 2014 10:13:56 -0700
I'd like my Objective-C framework to be nicer to use from Swift. For example, I'd like method parameters and return values to be declared as non-optional types when a nil value isn't allowed.
Apple seems to have done this with a lot of its classes, but I don't see how; I'd expect to find some annotations in the Obj-C headers but there aren't any. For example, NSDictionary.objectForKey takes parameter type AnyObject, not AnyObject!, but there's nothing special in the declaration of -objectForKey in NSDictionary.h.
In fact, in my classes I've already used __attribute__((nonnull)) to note parameters that aren't allowed to be nil; ideally the Swift translator should recognize that and make the parameter non-optional, but it doesn't look as though it does. I should file an ER on that.
Also, is there any way to view a translation of my class's interfaces into Swift, the way I can with system classes? For example, if I Cmd-click on UIApplication in a Swift source file I get an (automated?) Swift translation of UIApplication.h; whereas if I do that on one of my framework's classes it just opens up its regular .h file.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden