Re: Do NSStackView's actually work in a NSTableView?

2015-04-03 Thread Jonathan Mitchell
Obviously I am not sure whether you are introducing the NSStackView in to the table view in in IB or in code. Have you made sure that the NSStackView is fully constrained within the NSTableCellView? IB by default does not add constraints to NSView child items added to NSTableCellView instances.

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Charles Jenkins
I imagine you’re right, that they’re NString indexes packaged up into a frustrating return type. After sleeping on it, though, I imagined that even if complex grapheme clusters WERE to make count( attrStr.string ) return a different result than attrStr.length, it would probably never be due to

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Marco S Hyman
> extension Character { > > func isMemberOfSet( set:NSCharacterSet ) > -> Bool > { > // The for loop only executes once; > // its purpose is to convert Character to a type > // you can actually do something with > for char in String( self ).utf16 { > if set.character

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Quincey Morris
On Apr 3, 2015, at 04:00 , Charles Jenkins wrote: > > for char in String( self ).utf16 { > if set.characterIsMember( char ) { > return true > } Now we’re back to the place we started. This code is wrong. It fails for any code point that isn’t representable a single UTF-1

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Marco S Hyman
> On Apr 3, 2015, at 11:04 AM, Quincey Morris > wrote: > > On Apr 3, 2015, at 04:00 , Charles Jenkins wrote: >> >>for char in String( self ).utf16 { >> if set.characterIsMember( char ) { >>return true >> } > > Now we’re back to the place we started. This code is wrong.

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Quincey Morris
On Apr 3, 2015, at 11:19 , Marco S Hyman wrote: > > The original code will return true only if all code points map to white space. The “failure” I was talking about is something a bit different. It has two problems: 1. For Unicode code points that are represented by 2 code values, it tests the

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Charles Jenkins
So my Character.isMemberOfSet() is a poor general-purpose method, and I need to ditch it. I like your code. I had to modify it a bit so it wouldn’t fall on strings composed entirely of whitespace: let testString = "     \n\n \t\t" let attrStr = NSAttributedString( string:testString ) let str = 

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Quincey Morris
On Apr 3, 2015, at 13:18 , Charles Jenkins wrote: > > is there a way in the playground for use to test addresses to make sure > attrStr.string as NSString doesn’t perform a copy? I doubt it. This is the best I could come up with in a couple of minutes: > import Cocoa > > let notWhitespace =

Converting colorspace of a CGColor

2015-04-03 Thread Graham Cox
Is there a way to convert a CGColor to a different colorspace? It's trivial with NSColor, but I want to do the same at the lower CG level to keep the code as portable as possible between iOS and Mac. I'm sure I've done this in the past but I'm just not seeing the right function! --Graham ___

Re: Converting colorspace of a CGColor

2015-04-03 Thread edward m taffel
use ColorSync. Sent from my iPhone > On Apr 3, 2015, at 8:35 PM, Graham Cox wrote: > > Is there a way to convert a CGColor to a different colorspace? It's trivial > with NSColor, but I want to do the same at the lower CG level to keep the > code as portable as possible between iOS and Mac. I'

Re: Converting colorspace of a CGColor

2015-04-03 Thread Roland King
> On 4 Apr 2015, at 9:38 am, edward m taffel wrote: > > use ColorSync. > That’s most definitely not what Graham is looking for. He’s looking for a way to convert colours programatically, and cross-platform iOS and OSX (no colorsync on iOS). I just looked in my library of bits and pieces an

Re: Converting colorspace of a CGColor

2015-04-03 Thread Graham Cox
> On 4 Apr 2015, at 1:13 pm, Roland King wrote: > > That’s most definitely not what Graham is looking for. He’s looking for a way > to convert colours programatically, and cross-platform iOS and OSX (no > colorsync on iOS). That's right. In short, a CG equivalent to -[NSColor colorUsingColo

Re: Swift: How to determine if a Character represents whitespace?

2015-04-03 Thread Roland King
ok here’s my try, assuming NSLinguisticTagger knows what it’s doing. And yes it’s a bit stupid to use a linguistic tagger to do something like that but .. whatever var str = "Some String WIth Whitespace " var lt = NSLinguisticTagger( tagSchemes: [NSLinguisticTagSchemeTokenType], options: 0 )