Boolky Bear

When I first thought of a xml serializer written in Swift, the first thing that came to my mind was to write something that would take a dictionary as an input and return a string with the xml represented in the dictionary. That was, of course, the way I had done it before with Objective-C, where a NSDictionary had no type restriction on the keys apart of implementing the NSCopying protocol, or the values. While this is very easy to implement, it forces us to a lot of runtime type checking, to make sure the objects we want to serialize as xml are actually serializable.

In Swift, we can use the enums with associated values to define the types allowed in our xml serializer so we don’t need any runtime type checking. This is also safer as we know beforehand the types of the objects we have in our xml…

View original post 621 mots de plus

Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s