Re: [swift-users] CustomStringConvertible?

2017-09-09 Thread Joanna Carter via swift-users
Greetings

> 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.

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

You can also implement description as a let, since there is no intention to 
modify it :

class GPS : Powerable, CustomStringConvertible
{
  let description = "I am a GPS"
  
  …
}

Joanna

--
Joanna Carter
Carter Consulting

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


Re: [swift-users] XML parsing on Linux, with Swift 3.1

2017-09-09 Thread Georgios Moschovitis via swift-users
Thank you, I wasn’t aware of XMLDocument.
I managed to get XMLParser to work for my use case though…

-g.

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


Re: [swift-users] XML parsing on Linux, with Swift 3.1

2017-09-09 Thread Bouke Haarsma via swift-users

On 2017-09-05 06:01:55 +, Georgios Moschovitis via swift-users said:


Hi,

I would like to parse an RSS feed using Swift 3.1 on Linux.
I tried to use Foundations’s XML but I only managed to get segmentation faults.
Is this supposed to work on Linux? I have only seen examples on iOS.

Apart from that a quick search didn’t reveal any useful XML parsing 
library compatible with Linux.


Any suggestions?

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


XMLParser is a SAX-based parser, which is optimized for memory-usage. 
There's also XMLDocument, which is DOM-based and is optimized for 
developer convenience. If the XML files you're reading are small, i.e. 
few megabytes, DOM-based is usually the easiest way to handle such 
documents. XMLDocument is also implemented in Swift-Foundation, but I 
found that it was lacking too much functionality (e.g. namespacing). 
The situation might be different now -- you could check the source for 
`NSUnimplemented()`.


Other options is to link libxml2 (C library), however that requires 
much more effort on your end -- it doesn't expose high-level API's such 
as XMLDocument.


--Bouke


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