Cannot call value of non-function type "calendar"

Viewed 1474

I made a simple count down app and I get this wrong message: cannot call value of non-function type "calendar".

What I need to change?

    @IBOutlet weak var deteLabelOutlet: UILabel!
    let formatter = DateFormatter()
    let useCalendar = NSCalendar.current()
    let requesedComponent: NSCalendar.Unit = [
        NSCalendar.Unit.month,
        NSCalendar.Unit.day,
        NSCalendar.Unit.hour,
        NSCalendar.Unit.minute,
        NSCalendar.Unit.second
    ]

    override func viewDidLoad() {
        super.viewDidLoad()
        let timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(printTime), userInfo: nil, repeats: true)
        timer.fire()
    }

    func printTime() {
        formatter.dateFormat = "MM/dd/yy hh:mm:ss a"
        let startTime = Date()
        let endTime = formatter.date(from: String("12/25/16 12:00:00 a"))

        let timeDiffrenece = useCalendar.components(requesedComponent,fromDate: startTime, toDate: endTime!, options: [] )

        deteLabelOutlet.text = "\(timeDiffrenece.month)Month \(timeDiffrenece.day) days \(timeDiffrenece.minute) minutes \(timeDiffrenece.second) seconds"
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
1 Answers
Related