[swift-users] Printing Enums?

2017-07-17 Thread Michael Rogers via swift-users
Hi, All:

Can someone please enlighten me as to why the first enum works as expected, 
giving me Melbourne, but the second gives UIModalPresentationStyle rather than 
fullScreen? 


enum City {
case Melbourne, Chelyabinsk, Bursa
}
let city = City.Bursa

print(city)
// prints "Melbourne"

let cityName = "\(city)"   // or `let cityName = String(city)`
// cityName contains "Melbourne"

// Why doesn't the following work?

let presStyle = UIModalPresentationStyle.fullScreen

print(presStyle) // prints UIModalPresentationStyle

let presStyleName = "\(presStyle)"


I have an ugly work-around using String UIPresentationStyle tuples, but I'd 
rather not use it if possible.

Thanks,

Michael
---
Dr. Michael P. Rogers
Associate Professor, Northwest Missouri State University
Tinkerer-in-Chief and Angel Flight Pilot
Twitter & Google+:  mprog...@mac.com;  Skype: mprogersatmac.com; Facebook: 
mprogers
Phone:  309-825-6454 (H);  660-562-1551 (W)

Thank you, thank you, thank you, and I'd like to thank all the little people -- 
Tom Thumb, Ant-Man, and, of course, all the Lilliputians -- who made this award 
possible 

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


[swift-users] CustomStringConvertible?

2017-09-08 Thread Michael Rogers via swift-users
Quick question (for my own edification, as well as to demonstrate to my 
students the power of this mail list ), is CustomStringConvertible a stored 
property or a computed property? The docs say the latter, but when using 
Xcode’s fabulous FIX button, it seems to imply it’s a stored property. 

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


Re: [swift-users] CustomStringConvertible?

2017-09-08 Thread Michael Rogers via swift-users
Thanks for your reply, Rien. I just tried this again, and now it seems that 
either is acceptable. Seems a little weird, but I guess I’d rather have more 
flexibility than less.

protocol Powerable {
var isOn:Bool { get set } // Must have get and set
var usesDC:Bool { get } // Must have get, may have set
func turnOn()
func turnOff()
}

class GPS : Powerable, CustomStringConvertible {
// Either of these work
//var description: String {
//return "I am a GPS"
//}
var description:String = "I am a GPS"
var isOn: Bool = false
var usesDC: Bool = false

// does the obvious
func turnOn(){
isOn = true
}

// does the obvious
func turnOff() {
isOn = false
}
}

print(GPS()) // output: I am a GPS (both cases)

Michael

> On Sep 8, 2017, at 1:21 PM, Rien <r...@balancingrock.nl> wrote:
> 
> It cannot be ‘stored’ I would think.
> I always compute my implementations.
> 
> Regards,
> Rien
> 
> Site: http://balancingrock.nl
> Blog: http://swiftrien.blogspot.com
> Github: http://github.com/Balancingrock
> Project: http://swiftfire.nl - An HTTP(S) web server framework in Swift
> 
> 
> 
> 
> 
> 
> 
>> On 08 Sep 2017, at 19:47, Michael Rogers via swift-users 
>> <swift-users@swift.org> wrote:
>> 
>> Quick question (for my own edification, as well as to demonstrate to my 
>> students the power of this mail list ), is CustomStringConvertible a stored 
>> property or a computed property? The docs say the latter, but when using 
>> Xcode’s fabulous FIX button, it seems to imply it’s a stored property. 
>> 
>> Michael
>> ___
>> 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] Justification for Swift Design Decisions?

2017-10-31 Thread Michael Rogers via swift-users
Hi, All:

I’m giving a presentation on Swift this weekend, and am trying to find 
justification for some of the design decisions that they made. Is there 
anything out there that goes into the detail of this? Like … why did the use “ 
for characters, or \() for String interpolation?

Thanks,

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


Re: [swift-users] Justification for Swift Design Decisions?

2017-10-31 Thread Michael Rogers via swift-users


> On Oct 31, 2017, at 3:39 PM, Austin Zheng  wrote:
> 
> To expand on this, most (if not all) the proposals in the list of proposals 
> on GitHub (https://github.com/apple/swift-evolution/tree/master/proposals 
> ) have a 
> "Rationale" link to a mailing list archive post by one of the Swift core team 
> members explaining why a certain decision was reached. Those are probably 
> worth looking through. Some of the simpler and less controversial proposals 
> have almost no explanation, but the larger and controversial proposals have 
> extensively written-up rationale posts.

This is perfect, thank you! And it is comforting to see that so much thought 
went into these decisions ...

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