SEARU.ORG
当前位置:SEARU.ORG > Linux 软件 > 正文

XML 解析 AlamofireXmlToObjects

AlamofireXmlToObjects 可以抓取 XML 种子,并将他解析成对象。

代码示例:

class WeatherResponse: EVObject {
    var location: String?
    var three_day_forecast: [Forecast] = [Forecast]()
}

class Forecast: EVObject {
    var day: String?
    var temperature: NSNumber?
    var conditions: String?
}

class AlamofireXmlToObjectsTests {
    func testResponseObject() {
        let URL = "https://raw.githubusercontent.com/evermeer/AlamofireXmlToObjects/master/AlamofireXmlToObjectsTests/sample_xml"
        Alamofire.request(.GET, URL, parameters: nil)
        .responseObject { (response: WeatherResponse?, error: NSError?) in
            // That was all... You now have a WeatherResponse object with data
        }
    }
}

未经允许不得转载:SEARU.ORG » XML 解析 AlamofireXmlToObjects

赞 (0)
分享到:更多 ()

评论 0