It looks like your code should be:  

let theTabStop: NSTextTab = NSTextTab(type: .LeftTabStopType, location: 
tabInterval * cnt)

Check the documentation on NSTextTab here
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextTab_Class/#//apple_ref/occ/instm/NSTextTab/initWithType:location:
 
<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextTab_Class/#//apple_ref/occ/instm/NSTextTab/initWithType:location:>

and NSTextTabType here
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextTab_Class/#//apple_ref/c/tdef/NSTextTabType
 
<https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextTab_Class/#//apple_ref/c/tdef/NSTextTabType>

They have the Swift forms of the initializer and the enum that you want.



> On Aug 27, 2015, at 8:32 PM, Boyd Collier <[email protected]> wrote:
> 
> I’m in the process of re-writing some obj-c code in swift for OS X and am 
> stumped on how to set tab stops.  The relevant obj-c code looks like this:
> 
>               [paraStyle setTabStops:[NSArray array]];
>       for (cnt = 1; cnt <= numStops; cnt++) {
>               tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType 
> location: tabInterval * (cnt)];
>               [paraStyle addTabStop:tabStop];
>               [tabStop release];
>       }
>       [attrs setObject:paraStyle forKey:NSParagraphStyleAttributeName];
>       [paraStyle release];
>       
>       [[textView textStorage] addAttributes:attrs range:NSMakeRange(0, 
> [[[textView textStorage] string] length])];
>       [attrs release];
> 
> Most of my swift code compiles, but not the line corresponding to tabStop = 
> [[NSTextTab alloc] initWithType:NSLeftTabStopType location: tabInterval * 
> (cnt)];
> 
> I’ve tried 
>       let theTabStop: NSTextTab = NSTextTab(NSLeftTabStopType, loc, 
> (tabInterval * cnt))
> 
> but am told that NSLeftTabStopType is an “unresolved identifier”, which I 
> understand has to do with enums being quite different in swift.
> Surely, the correct way to deal with this is relatively simple, but I’ve not 
> yet come up with it.  Any help would be greatly appreciated.
> 
> Boyd
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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/marckhadpe%40gmail.com
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to