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.

Community
  • 1
  • 1
Quincy
  • 1,710
  • 14
  • 20
  • 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. – mattt Feb 03 '15 at 23:58
  • 3
    See if there isn't a stray `init` with a `data` parameter around. – mattt Feb 03 '15 at 23:58
  • 2
    yes!!!! God bless the woman that gave birth to your brain! :) – Quincy Feb 04 '15 at 00:50

1 Answers1

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)
Quincy
  • 1,710
  • 14
  • 20
  • 2
    For reference, it's the same automatic process by which `NSString +stringWithX:` constructors are bridged to `NSString(X:)` in Swift. – mattt Feb 04 '15 at 01:16
  • 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. – Quincy Feb 04 '15 at 02:06