2015-09-07 86 views
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 
    } 

我我宣佈錯了?

+0

如果將數組聲明更改爲var projectList = [teamProjects]() – Devster101

回答

0

您實際上沒有做錯什麼,在我的Xcode 7 beta 6中,以下代碼片段沒有引人注目的錯誤。一般來說,你聲明的功能是正確的。

相關問題