Re: using constants from Obj-c in swift

2015-09-25 Thread Boyd Collier
Charles & Marco,

Thanks very much for the prompt replies.  I think I’d tried 
scrollView.borderType = .NSNoBorder (and lots of other things), but didn’t 
think of leaving off the “NS”.

Boyd


> On Sep 25, 2015, at 12:12 PM, Marco S Hyman  wrote:
> 
> On Sep 25, 2015, at 11:43 AM, Boyd Collier  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

Re: swift: windowControllerDidLoadNib called twice

2015-09-25 Thread Lee Ann Rucker
I had one of those. Apple would send out updates - “please replace page X with 
pages X1-X20"

On Sep 25, 2015, at 10:56 AM, Peter Teeson  wrote:

> FWIW before the nice hardcover books there was a single (as I recall) loose 
> leaf binder with documentation for the 128K.
> 
>> On Sep 25, 2015, at 1:06 PM, Raglan T. Tiger  wrote:
>> 
>> 
>>> On Sep 23, 2015, at 1:08 PM, Boyd Collier  wrote:
>>> 
>>> I’ve been writing code for Macs off-and-on for 30 years,
>> 
>> 
>> I still have my original copy of Inside Macintosh !
>> 
>> IM Fun 1 
>> >  >
>> IM Fun 2 
>> >  >
>> 
>> 
>> -rags
>> ___
>> 
>> 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/pteeson%40icloud.com
>> 
>> This email sent to ptee...@icloud.com
> 
> 
> ___
> 
> 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/lrucker%40vmware.com
> 
> This email sent to lruc...@vmware.com


___

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

Re: using constants from Obj-c in swift

2015-09-25 Thread Marco S Hyman
Arrgh... typo

> scrollview.borderType = NoBorder

That should be 

scrollview.borderType = .NoBorder

of course.  How come I never see that kind of thing until AFTER I hit send.
___

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

Re: using constants from Obj-c in swift

2015-09-25 Thread Marco S Hyman
On Sep 25, 2015, at 11:43 AM, Boyd Collier  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

Re: using constants from Obj-c in swift

2015-09-25 Thread Charles Srstka
> On Sep 25, 2015, at 1:43 PM, Boyd Collier  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.
> Is there a straightforward way to do this?  (I’m using swift 2 in Xcode 7)

Generally speaking, Objective-C enums get simplified in Swift so that the 
common prefixes are removed from the name of the constant. You access an enum 
by typing the enum type name, then a period, then the constant name (in your 
case, NSBorderType.NoBorder). However, if you have a property or parameter that 
is defined as that enum type, you can leave the enum type name out, and the 
compiler will infer it. So, all you have to do is this:

scrollView.borderType = .NoBorder

Charles


___

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

using constants from Obj-c in swift

2015-09-25 Thread Boyd Collier
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.
Is there a straightforward way to do this?  (I’m using swift 2 in Xcode 7)

Boyd
___

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

Re: swift: windowControllerDidLoadNib called twice

2015-09-25 Thread Peter Teeson
FWIW before the nice hardcover books there was a single (as I recall) loose 
leaf binder with documentation for the 128K.

> On Sep 25, 2015, at 1:06 PM, Raglan T. Tiger  wrote:
> 
> 
>> On Sep 23, 2015, at 1:08 PM, Boyd Collier  wrote:
>> 
>> I’ve been writing code for Macs off-and-on for 30 years,
> 
> 
> I still have my original copy of Inside Macintosh !
> 
> IM Fun 1 
> IM Fun 2 
> 
> 
> -rags
> ___
> 
> 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/pteeson%40icloud.com
> 
> This email sent to ptee...@icloud.com


___

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

Re: swift: windowControllerDidLoadNib called twice

2015-09-25 Thread Raglan T. Tiger

> On Sep 23, 2015, at 1:08 PM, Boyd Collier  wrote:
> 
>  I’ve been writing code for Macs off-and-on for 30 years,


I still have my original copy of Inside Macintosh !

IM Fun 1 
IM Fun 2 


-rags
___

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