Re: More elegance than a long if/else

2017-03-10 Thread Pascal Bourguignon
> On 10 Mar 2017, at 23:32, Quincey Morris > wrote: > > On Mar 10, 2017, at 08:24 , Bryan Vines wrote: >> >> Would integer division work better than the modulus operator? > > It would certainly work better in the sense that division is

Re: More elegance than a long if/else

2017-03-10 Thread Quincey Morris
On Mar 10, 2017, at 08:24 , Bryan Vines wrote: > > Would integer division work better than the modulus operator? It would certainly work better in the sense that division is the right operator and modulus is the wrong one! Regarding the original question, I would add that

Re: More elegance than a long if/else

2017-03-10 Thread Bryan Vines
Would integer division work better than the modulus operator? batteryIcon.image = UIImage(named:"\(min(10, (Int(_myBatteryLevel) / 10) + 1))") -- Bryan Vines > On Mar 10, 2017, at 9:54 AM, Jeff Kelley wrote: > > I realized after sending that 100 won’t be correct, so

struts and springs layout

2017-03-10 Thread Jonathan Mitchell
In Xcode 8 we can use struts and springs style layout until we add an explicit constraint. The idea seems to be that the strut + spring definition get turned into constraints. However, querying NSView -constraints returns nothing in this case, nor does the debug view hierarchy. Is it just

Re: More elegance than a long if/else

2017-03-10 Thread Jeff Kelley
I realized after sending that 100 won’t be correct, so you’ll need something like this: batteryIcon.image = UIImage(named: "\(min(10, (_myBatteryLevel % 10) + 1))") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org On Fri, Mar 10, 2017 at

Re: More elegance than a long if/else

2017-03-10 Thread Eric E. Dolecki
Thank you! On Fri, Mar 10, 2017 at 10:48 AM Jeff Kelley wrote: > Something like this should work: > > batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") > > > Jeff Kelley > > slauncha...@gmail.com | @SlaunchaMan | >

Re: More elegance than a long if/else

2017-03-10 Thread Jeff Kelley
Something like this should work: batteryIcon.image = UIImage(named: "\((_myBatteryLevel % 10) + 1)") Jeff Kelley slauncha...@gmail.com | @SlaunchaMan | jeffkelley.org On Fri, Mar 10, 2017 at 10:41 AM, Eric E. Dolecki wrote: > I have this

More elegance than a long if/else

2017-03-10 Thread Eric E. Dolecki
I have this super simple code, but I'd like to whittle it down to something a lot smaller - basically looking for multiples of 10 (100-0) for a value. I need coffee, what's a great way to do this in Swift 3? if _myBatteryLevel >= 90 { batteryIcon.image = UIImage(named: "10") }

Re: needsDisplay and subviews

2017-03-10 Thread Jeremy Hughes
> On 9 Mar 2017, at 18:32, corbin dunn wrote: > >> >> On Mar 8, 2017, at 8:46 AM, Jeremy Hughes >> wrote: >> >> If needsDisplay is set to true for an NSView, does that also cause subviews >> to be redrawn? >> >> I’ve seen conflicting

Re: How do I use a NSTextBlock in an attributed string?

2017-03-10 Thread Daryle Walker
> On Mar 9, 2017, at 7:05 AM, Daryle Walker wrote: > >> >> On Mar 8, 2017, at 4:17 PM, Daryle Walker wrote: >> >> I tried: >> >>> // Set the paragraph formatting for the body... >>> let bodyAdvancement = bodyFont.maximumAdvancement >>>