Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to prevent array of days from being selected? #236

Closed
dantetemp opened this issue Mar 25, 2016 · 1 comment
Closed

how to prevent array of days from being selected? #236

dantetemp opened this issue Mar 25, 2016 · 1 comment

Comments

@dantetemp
Copy link

when i paste the code from MOREUSAGE.md

func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
if dateShouldNotBeSelected {
return false
}
return true
}

i get error: use of unresolved identifier dateShouldNotBeSelected

i have an array of dates, how do i prevent those dates from being selected?

@dantetemp
Copy link
Author

i found the solution.
i'm a newbie coder, so the information in MOREUSAGE.md was not very clear.

    func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
        let xday = [ NSDate(date: "2016-03-22"), NSDate(date: "2016-03-23") ]
        if xday.contains(date) {
            print("date is not selectable")
            return false
        }
        return true
    }

extension NSDate {
    convenience init (date: String, format: String = "yyyy-MM-dd") {
        let dateStringFormatter = NSDateFormatter()
        dateStringFormatter.dateFormat = format
        dateStringFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
        let d = dateStringFormatter.dateFromString(date)!
        self.init(timeInterval: 0, sinceDate: d)

        // examples
        // NSDate(date: "2014-01-06")
        // NSDate(date: "2015", format: "yyyy")
    }
}

issue is closed. thank your for the calendar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant