1
我正在製作一個iOS應用程序,我試圖用Osmosis從網站獲取一些數據並將其顯示在我的應用程序中。爲此,我按照github上的自述文件中描述的usage。使用陣列與滲透
我的問題是,我試圖獲取解析的信息時出現錯誤。下面是我的代碼片段:
class ViewController: UIViewController {
var array: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Osmosis(errorHandler: { (error) -> Void in
print(error)
})
.get(NSURL(string: "www.mysite.com")!)
.find(OsmosisSelector(selector: ".quote"), type: .CSS)
.populate([
OsmosisPopulateKey.Single("quotes") : OsmosisSelector(selector: "tt_quotes b")
], type: .CSS)
.list { (dict) -> Void in
self.array.append(dict)
.start()
print(dict)
當我嘗試建立我的項目,我得到以下錯誤:
ViewController.swift:34:35: Cannot convert value of type '[String : AnyObject]' to expected argument type 'String'
爲什麼我的項目崩盤和我應該如何聲明我的數組,以使其正常工作?
謝謝您的回答,但是當我這樣做,我得到以下錯誤: 'ViewController.swift:34:28 :元組類型'()'的值沒有成員'start'' – Mehdi
@Mehdi編輯我的答案以解決第二個問題。 – JAL
愚蠢的錯誤..謝謝! – Mehdi