Re: using constants from Obj-c in swift
Re: using constants from Obj-c in swift
- Subject: Re: using constants from Obj-c in swift
- From: Marco S Hyman <email@hidden>
- Date: Fri, 25 Sep 2015 12:12:34 -0700
On Sep 25, 2015, at 11:43 AM, Boyd Collier <email@hidden> wrote:
>
> In objective-c programs, there are places where one can write lines like the following:
>
> [scrollview setBorderType:NSNoBorder];
>
> with NSNoBoarder being specified in an enum in NSView. But enums in swift are a different sort of beast, and I’ve not yet figured out what get the same job done.
Swift will replace an accessor like setFoo with direct access to the property foo. For your case the documentation for setBorderType says the swift version is
var borderType: NSBorderType
If you then look at NSBorderType you’ll see this:
enum NSBorderType : UInt {
case NoBorder
case LineBorder
case BezelBorder
case GrooveBorder
}
> Is there a straightforward way to do this? (I’m using swift 2 in Xcode 7)
Translating [scrollview setBorderType:NSNoBorder]; to swift is
scrollview.borderType = NoBorder
After doing this a few times the pattern will become pretty obvious and you’ll need to go to the doc less and less.
Marc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden