AlamofireXmlToObjectsXML 解析
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 } } }
评论