Re: setting tab stops in swift
Re: setting tab stops in swift
- Subject: Re: setting tab stops in swift
- From: Quincey Morris <email@hidden>
- Date: Sat, 29 Aug 2015 18:52:22 +0000
On Aug 29, 2015, at 11:36 , Boyd Collier <email@hidden> wrote:
>
> In my swift code, I’ve tried just about every permutation I can think of to get the type of tab or alignment that I want, but to no avail. It occurred to me that perhaps swift 1.2, which is what I’m using, might not work; I’ll give swift 2 a try.
The fundamental problem is that the line of code you wrote is not valid syntax in any version of Swift:
> let theTabStop: NSTextTab = NSTextTab(NSLeftTabStopType, loc, (tabInterval * cnt))
The first parameter (whatever the correct spelling) belongs to the 2-parameter initializer, and the 3-parameter initializer has a dictionary as the 3rd parameter. Plus, you’re missing keywords on the parameters.
Next, it was important information that you’re using Swift 1.2 rather than 2. The bridging of many enums was refined since Swift 1.2, so if you’re looking at NSTextTab documentation you have to make sure you’re looking at the old Swift 1.2 documentation, or you’re likely to get the wrong answer.
You can find out the correct way to write the enum value by Command-clicking on the word NSTextTab to see the bridged header. (This may not work if there’s a syntax error on the line, so you may have to get it error free on a separate line, e.g. as a pure declaration.) Look around in or near the NSTextTab class definition for the enum your version of the compiler is using.
Lastly, you’re making life very, very hard for yourself if you’re still using Swift 1.2. If you *must* use a non-beta version of Xcode (for the next month or two until it’s Xcode 7 is released), then I supposed you have to stay there. Otherwise, switch to Swift 2.
_______________________________________________
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