Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Chris Lattner via swift-users

> On May 11, 2016, at 7:37 AM, Erica Sadun via swift-users 
>  wrote:
> 
>> 
>>> On May 11, 2016, at 9:57 AM, Dennis Weissmann >> > wrote:
>>> 
>>> Huh! There’s a new overload for that initializer:
>>> 
>>> 
>>> 
>>> The one that takes CGFloats is the one that was there before, but the one 
>>> taking Floats is new!
>>> 
>>> You can work around like this:
>>> 
>>> let color = UIColor(red: CGFloat(0.892), green: CGFloat(0.609), blue: 
>>> CGFloat(0.048),  alpha: CGFloat(1.000))
>>> or
>>> let color = UIColor(red: Float(0.892), green: Float(0.609), blue: 
>>> Float(0.048),  alpha: Float(1.000))
>>> 
>>> - Dennis
> 
> 
> Wow, that's a ridiculous situation to have.  Who uses Float with iOS/tvOS 
> anyway? 
> 
> I created a workaround, but I hate it:

This is a known regression that is a fallout of the changes to playground 
literals, it is high priority to get fixed.

-Chris

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Charles Lane via swift-users
I agree, however, I like your workaround better than all the extra parentheses 
and CGFloats!



> On May 11, 2016, at 10:37 AM, Erica Sadun  wrote:
> 
>> 
>>> On May 11, 2016, at 9:57 AM, Dennis Weissmann >> > wrote:
>>> 
>>> Huh! There’s a new overload for that initializer:
>>> 
>>> 
>>> 
>>> The one that takes CGFloats is the one that was there before, but the one 
>>> taking Floats is new!
>>> 
>>> You can work around like this:
>>> 
>>> let color = UIColor(red: CGFloat(0.892), green: CGFloat(0.609), blue: 
>>> CGFloat(0.048),  alpha: CGFloat(1.000))
>>> or
>>> let color = UIColor(red: Float(0.892), green: Float(0.609), blue: 
>>> Float(0.048),  alpha: Float(1.000))
>>> 
>>> - Dennis
> 
> 
> Wow, that's a ridiculous situation to have.  Who uses Float with iOS/tvOS 
> anyway? 
> 
> I created a workaround, but I hate it:
> 
> extension Double {
> var cg: CGFloat { return CGFloat(self) }
> }
> 
> class ViewController: UIViewController {
> override func viewDidLoad() {
> super.viewDidLoad()
> let c = UIColor(red: 0.5.cg, green: 0.5, blue: 0.5, alpha: 0.5)
> }
> }
> 
> -- E
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Erica Sadun via swift-users
> 
>> On May 11, 2016, at 9:57 AM, Dennis Weissmann > > wrote:
>> 
>> Huh! There’s a new overload for that initializer:
>> 
>> 
>> 
>> The one that takes CGFloats is the one that was there before, but the one 
>> taking Floats is new!
>> 
>> You can work around like this:
>> 
>> let color = UIColor(red: CGFloat(0.892), green: CGFloat(0.609), blue: 
>> CGFloat(0.048),  alpha: CGFloat(1.000))
>> or
>> let color = UIColor(red: Float(0.892), green: Float(0.609), blue: 
>> Float(0.048),  alpha: Float(1.000))
>> 
>> - Dennis


Wow, that's a ridiculous situation to have.  Who uses Float with iOS/tvOS 
anyway? 

I created a workaround, but I hate it:

extension Double {
var cg: CGFloat { return CGFloat(self) }
}

class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let c = UIColor(red: 0.5.cg, green: 0.5, blue: 0.5, alpha: 0.5)
}
}

-- E

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Initializing a UIColor

2016-05-11 Thread Dennis Weissmann via swift-users
Huh! There’s a new overload for that initializer:



The one that takes CGFloats is the one that was there before, but the one 
taking Floats is new!

You can work around like this:

let color = UIColor(red: CGFloat(0.892), green: CGFloat(0.609), blue: 
CGFloat(0.048),  alpha: CGFloat(1.000))
or
let color = UIColor(red: Float(0.892), green: Float(0.609), blue: Float(0.048), 
 alpha: Float(1.000))

- Dennis

> On May 11, 2016, at 3:46 PM, Charles Lane via swift-users 
>  wrote:
> 
> The following code worked fine in previous development snapshots but fails in 
> the May 9, 2016 snapshot:
> 
>   let color = UIColor(red: 0.892, green: 0.609, blue: 0.048,  alpha: 
> 1.000)
> 
> Does anyone know whether this is a bug or if the syntax changed? (Yes, I 
> imported UIKit). Xcode gives an error of ‘Ambiguous use of 
> init(red:green:blue:alpha:)’
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Initializing a UIColor

2016-05-11 Thread Charles Lane via swift-users
The following code worked fine in previous development snapshots but fails in 
the May 9, 2016 snapshot:

let color = UIColor(red: 0.892, green: 0.609, blue: 0.048,  alpha: 
1.000)

Does anyone know whether this is a bug or if the syntax changed? (Yes, I 
imported UIKit). Xcode gives an error of ‘Ambiguous use of 
init(red:green:blue:alpha:)’


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users