squimer / DatePickerDialog-iOS-Swift

Date picker dialog for iOS
MIT License
581 stars 177 forks source link

Swift 3 port necessary #34

Closed benjohnde closed 7 years ago

lfarah commented 7 years ago

@benjohnde Still getting this error

screen shot 2016-09-16 at 10 01 39 am
benjohnde commented 7 years ago

Check, that's in your demo project as the syntax has changed. I am working on it. You will receive another PR today. The actual library is working as intended.

As of now, the func datePickerTapped should be like the following:

    /* IBActions */
    @IBAction func datePickerTapped(sender: AnyObject) {
        let currentDate = Date()
        var dateComponents = DateComponents()
        dateComponents.month = -3
        let threeMonthAgo = Calendar.current.date(byAdding: dateComponents, to: currentDate)

        DatePickerDialog().show(title: "DatePickerDialog", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", minimumDate: threeMonthAgo, maximumDate: currentDate, datePickerMode: .date) {
            (date) -> Void in
            if let dt = date {
                self.textField.text = "\(dt)"
            } else {
                print("")
            }
        }

    }

Cheers, Ben!

benjohnde commented 7 years ago

You may also need to set the project you are using to the latest Swift syntax.

You can achieve that by explicitly setting "Use Legacy Swift Language Version" to "No" under "Build Settings". Saying that, I assume you are using the latest Xcode 8 😃