void函数中的意外非空返回值(Swift 2)

时间:2016-05-18 18:27:32

标签: firebase swift2 xcode7 tableviewcell sections

尝试使用从firebase中提取的数据填充表格视图。我最初能够使用静态数据运行应用程序,但是当我实现了来自firebase的pull时,我开始得到错误" void函数中出现意外的非void返回值"在我返回sections数组之后。

import Foundation
import Firebase 

class SectionsData {

var users = [User]()
var currentUser: User!
var userKey: String?

func getSectionsFromData() -> [Section] {


    DataService.ds.CURRENT_USER_REF.observeEventType(.Value, withBlock: {snapshot in

        print(snapshot.value)

        self.users = []

        if let currentUserDict = snapshot.value as? Dictionary<String, AnyObject> {

            let key = snapshot.key
            let currentUser = User(userKey: key, dictionary: currentUserDict)
            self.users.append(currentUser)

            var sectionsArray = [Section]()

            let jobType = Section(title: "Type of Job I'm looking for:", objects: ["A really cool one"])
            let bio = Section(title: "Bio:", objects: [(currentUserDict["userBio"] as? String)!])
            let atts = Section(title: "What I bring to the table:", objects: [(currentUserDict["userAtt1"] as? String)!, (currentUserDict["userAtt2"] as? String)!, (currentUserDict["userAtt3"] as? String)!])


            sectionsArray.append(jobType)
            sectionsArray.append(bio)
            sectionsArray.append(atts)

            return sectionsArray //error occurs here

        }



    })

任何人都可以帮忙吗?提前谢谢!

0 个答案:

没有答案