mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-29 19:11:24 +01:00
29 lines
612 B
Swift
29 lines
612 B
Swift
//
|
|
// FeedTitleDownloader.swift
|
|
// Evergreen
|
|
//
|
|
// Created by Brent Simmons on 9/3/16.
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import RSXML
|
|
import RSWeb
|
|
|
|
func downloadTitleForFeed(_ url: URL, _ completionHandler: @escaping (_ title: String?) -> ()) {
|
|
|
|
download(url) { (data, response, error) in
|
|
|
|
guard let data = data else {
|
|
completionHandler(nil)
|
|
return
|
|
}
|
|
|
|
let xmlData = RSXMLData(data: data, urlString: url.absoluteString)
|
|
RSParseFeed(xmlData) { (parsedFeed : RSParsedFeed?, error: Error?) in
|
|
|
|
completionHandler(parsedFeed?.title)
|
|
}
|
|
}
|
|
}
|