I'm making a schedule app using FSCalender library.
Under the numberofevents func (for making an dot if returns an int), I'm fetching a data from Firebase database and trying show the dot if there's a date stored in the database.
However, after returning int, the error occurs:
Unexpected non-void return value in void function
Because of this third-party library, I really got stuck at fixing this error. Any ideas to solve this problem? Thanks in advance.
//function for making dot: we want to make dots after selecting and saving time
func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {
// fetching from firebase db. if there is a date stored on the date, a dot will be shown
let tmpDate = Calendar(identifier: .gregorian)
let year = tmpDate.component(.year, from: date)
let month = tmpDate.component(.month, from: date)
let day = tmpDate.component(.day, from: date)
let m = String(format: "%02d", month)
let d = String(format: "%02d", day)
let da = "\(year)/\(m)/\(d)"
if let uid = Auth.auth().currentUser?.uid {
let ref = Database.database().reference().child("schedule").child(uid)
ref.observe(.childAdded, with: { (snapshot) in
//print(snapshot.value)
guard let dictionary = snapshot.value as? [String: Any] else {return}
Database.fetchUserWithUID(uid: uid, completion: { (user) in
let schedule = Schedule(user: user, dictionary: dictionary)
if schedule.date == da {
print("a dot will show")
return 1 //Error "Unexpected non-void return value in void function" occurs here
}
})
}) { (err) in
print("failed to fetch data")
}
}
return 0
}