1

For my swift iPhone app I'm needing to parse XML.

I'm using Alamofire and trying to use Ono which is an objective c library. I used cocoapods to install Alamofire & Ono.

I've followed the steps here: How to integrate Cocoapods with a Swift project?

where I have #import <Ono/Ono.h> in my bridging header.

Whats very odd is that in swift I can reference many of the Ono classes, but there is one function XMLDocumentWithData that I can't. E.g. HTMLDocumentWithString I can call, but XMLDocumentWithData I can't.

3
  • 3
    XMLDocumentWithData / String are probably being slurped up as initializers by the automatic source bridge, since its name, ONOXMLDocument +XMLDocumentWithData: shares a common prefix and has an instancetype return type that would indicate that it is a constructor. Commented Feb 3, 2015 at 23:58
  • 3
    See if there isn't a stray init with a data parameter around. Commented Feb 3, 2015 at 23:58
  • 2
    yes!!!! God bless the woman that gave birth to your brain! :) Commented Feb 4, 2015 at 0:50

1 Answer 1

1

As mattt points out in his comment, somehow the code generation has "slurped" up the goods.

Below is how you can call the method instead for now:

let XML = ONOXMLDocument(data: data, error: &XMLSerializationError)
//let XML = ONOXMLDocument.XMLDocumentWithData(data, error: &XMLSerializationError)
Sign up to request clarification or add additional context in comments.

2 Comments

For reference, it's the same automatic process by which NSString +stringWithX: constructors are bridged to NSString(X:) in Swift.
ah ok. Sorry, I'm a newb didn't put that together for myself. Maybe you could update the Alamofire documentation "Creating a Custom Response Serializer" to with ONOXMLDocument(data, error) instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.