0
當我嘗試返回var projectList時,出現編譯時錯誤witch是我創建的給定結構中的列表。我得到的編譯錯誤是:'[teamProjects]'不能轉換爲void。但我相信,functioin爲類型[teamProjects]嘗試使函數返回一個列表時發生錯誤
這裏是我的代碼:
func makeHTTPRequest(url: String, usr: String, pw: String) -> [teamProjects]{
var projectList: [teamProjects] = []
for index in 0...(count-1) {
let id = jsonOBJ[index]["id"].string as String! ?? ""
let name: String = jsonOBJ[index]["name"].string as String! ?? ""
let desc: String = jsonOBJ[index]["description"].string as String! ?? ""
let url: String = jsonOBJ[index]["url"].string as String! ?? ""
let state: String = jsonOBJ[index]["state"].string as String! ?? ""
let revision: Int = jsonOBJ[index]["revision"].int as Int! ?? 0
let teamProject: teamProjects = teamProjects(id: id, name: name,
description: desc, url: url, state: state, revision: revision)
projectList.append(teamProject);
}
println(projectList)
return projectList
}
我我宣佈錯了?
如果將數組聲明更改爲var projectList = [teamProjects]() – Devster101