Code Monkey home page Code Monkey logo

Comments (9)

aosterthun avatar aosterthun commented on June 2, 2024 2

Ok I fixed it.
You should maybe edit your README.md from:
(response: WeatherResponse?, error: NSError?)
to:
(response: Result< WeatherResponse,NSError>)

from alamofirexmltoobjects.

aosterthun avatar aosterthun commented on June 2, 2024 2

Ok last comment (I swear :D ) I also got that to work.
Last I have some general comments to the lib.
In my case I had to define a __name var for a tag that didn't had any properties it now stores the name of the tag don't know why that there don't have it in any other case.
It would be nice if the whitespace would be removed automatically so you don't have to write the underscore in front of every property.

But all in all I'm really happy that I didn't had to write such a lib by myself. So at the and a big thanks! Will recommend it!

from alamofirexmltoobjects.

aosterthun avatar aosterthun commented on June 2, 2024 1

First I'm really thankful you replied that fast (or at all) !

After updating the Podfile (don't wonder it's a .txt couldn't upload it otherwise) I got the example project to work.
Podfile.txt
I'm still wondering why it throughs that error in my project, because I installed the same dependencies.
Podfile[custom].txt

If it helps I could add you to the repo I'm trying to install it on.

from alamofirexmltoobjects.

evermeer avatar evermeer commented on June 2, 2024

If you download AlamofireXmlToObject (press download zip at https://github.com/evermeer/AlamofireXmlToObjects) and then execute a pod update from the terminal you should see that the folowing 2 library versions are loaded:

  • Alamofire (3.4.0)
  • EVReflection (2.31.0)
    After that you should be able to run the tests

from alamofirexmltoobjects.

aosterthun avatar aosterthun commented on June 2, 2024

Other question how do I represent properties of tags in a class ? Which datatypes do I use ? For example I have the following xml tag:
<device name="HM-CC-RT-DN KEQ0652567" ise_id="1237" unreach="false" sticky_unreach="false" config_pending="false">

from alamofirexmltoobjects.

evermeer avatar evermeer commented on June 2, 2024

Ah! yes, the signature was changed quite some time ago... I will update the sample in a moment.

In your sample you will get a sub object for device. That device sub object will have a _name, _ise_id, _unreach, _sticky_unreach and _config_pending property. attributes will get an underscore in front of the name.

You can see how this works in the test that you can find here:

You could also just define 1 object without properties and run it. In the console log you will find warnings that specific properties could not be found. Then just add those properties to your object.

from alamofirexmltoobjects.

evermeer avatar evermeer commented on June 2, 2024

The __name and the _ for attributes comes from the XML2Dictionary library. That is a library that is not written by me.

AlamofireXMLToObjects itself has a very limited implementation. It's only a bridge between XML2Dictionary, AlamoFire and EVReflection. See here the entire code of the library. See how small it is? AlamofireXmlToObject library It's only 70 lines of which half is comment.

from alamofirexmltoobjects.

aosterthun avatar aosterthun commented on June 2, 2024

Ok I didn't knew that I relatively new to swift programming and therefore don't know many of the common libs. Normally I'm working in C++, C, PHP, Python and some other Web languages.

from alamofirexmltoobjects.

evermeer avatar evermeer commented on June 2, 2024

Tip: EVReflection supports property mapping. You can use that to ignore properties or to change a property name. For instance you could Implement something like this:

    override public func propertyMapping() -> [(String?, String?)] {
        return [("__name", nil), ("_name", "Name"), ("ise_id", "IseId")]
    }

You could also put that in a base class so that it's used in all your objects.
in the case above the __name will be ignored and _name will be changed to Name

from alamofirexmltoobjects.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.