Trying to populate a table view with data pulled from firebase. I initially was able to run the app with static data but when I implemented the pull from firebase I started getting the error "Unexpected non-void return value in void function" after I return the sections array.
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
}
})
Can anyone help with this? Thank you in advance!