setting tab stops in swift
setting tab stops in swift
- Subject: setting tab stops in swift
- From: Boyd Collier <email@hidden>
- Date: Thu, 27 Aug 2015 17:32:51 -0700
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@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