On Sep 25, 2015, at 11:43 AM, Boyd Collier <bcoll...@mail.sdsu.edu> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to