Bridge Swift to Objective-C library “ono” using cocoapods

风格不统一 提交于 2020-01-23 23:27:07

问题


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.


回答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)


来源:https://stackoverflow.com/questions/28304032/bridge-swift-to-objective-c-library-ono-using-cocoapods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!