我正在尝试将日期和时间从UIDatePicker上传到Firebase数据库

时间:2018-08-30 13:12:48

标签: firebase firebase-realtime-database uidatepicker

由于未捕获的异常'InvalidFirebaseData'而终止应用程序,原因:'(setValue :)迄今为止无法存储__NSTaggedDate类型的对象。只能存储NSNumber,NSString,NSDictionary和NSArray类型的对象。

 @IBOutlet weak var startDatePicker: UIDatePicker!

//////////用于设置日期限制的代码

    let startDate = UIDatePicker()
    let toDate = NSDate()
    startDate.addTarget(self, action: Selector(("selectStartDate")), for: UIControlEvents.valueChanged)
    var thirtyDays = TimeInterval()
    thirtyDays = 30 * 24 * 60 * 60

    let thirtyDaysFromToDate = toDate.addingTimeInterval(thirtyDays)

    startDatePicker.minimumDate = toDate as Date
    startDatePicker.maximumDate = thirtyDaysFromToDate as Date

/////////数据库中的上传代码

    ["email":email,"lat":Location1.latitude,"lon":Location1.longitude,"date":startDatePicker.date]

0 个答案:

没有答案