How to Add events to FSCalendar Swift?

fscalendar swift tutorial
fscalendar documentation
add event to calendar swift 4
fscalendar calendar
swift add event to google calendar
swift 5 add calendar event
fscalendar get selected date swift
fscalendar week view

I am using FSCalendar to add calendar UI in my project . But I am unable to find any solution to add events to the calendar. So any ideas on how to add events to FSCalendar or any third party calendar framework?

To Set Events Base On Dates..

Instance of DateFormatter And Variables:

var datesWithEvent = ["2015-10-03", "2015-10-06", "2015-10-12", "2015-10-25"]

var datesWithMultipleEvents = ["2015-10-08", "2015-10-16", "2015-10-20", "2015-10-28"]

fileprivate lazy var dateFormatter2: DateFormatter = {
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd"
    return formatter
}()

next is... DataSource Function:

func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {

    let dateString = self.dateFormatter2.string(from: date)

    if self.datesWithEvent.contains(dateString) {
        return 1
    }

    if self.datesWithMultipleEvents.contains(dateString) {
        return 3
    }

    return 0
}

I Hope This Help You, This Code is Base On FsCalendar Sample Project.

ios: How to Add events to FSCalendar Swift?, WenchaoD I downloaded the example and have go through this many times and I'm trying to implement following code using swift 3 but its not  How to Add events to FSCalendar Swift? 304. How to program a delay in Swift 3. 1. FSCalendar - Change bg color of selected dates Swift 3? 1.

I have an array that contains events's dates and the number of event on this date what I did is:

1- Comparing dates(comparing dates without time using compareDate(data.eventDate!, toDate: date, toUnitGranularity: .Day)) from my array with date(in the function)

2- If they're equal I'll add date to an array(datesWithEvent) without time so I can compare it later without problems

3- return true when it finds the right dates

var datesWithEvent:[NSDate] = []
func calendar(calendar: FSCalendar, hasEventForDate date: NSDate) -> Bool {
    for data in eventsArray{
        let order = NSCalendar.currentCalendar().compareDate(data.eventDate!, toDate: date, toUnitGranularity: .Day)
        if order == NSComparisonResult.OrderedSame{
            let unitFlags: NSCalendarUnit = [ .Day, .Month, .Year]
            let calendar2: NSCalendar = NSCalendar.currentCalendar()
            let components: NSDateComponents = calendar2.components(unitFlags, fromDate: data.eventDate!)
            datesWithEvent.append(calendar2.dateFromComponents(components)!)
        }
    }
    return datesWithEvent.contains(date)
}

And to precise the number of event on this date (different number of dots) I've added this code

func calendar(calendar: FSCalendar, numberOfEventsForDate date: NSDate) -> Int {
    for data in eventsArray{
        let order = NSCalendar.currentCalendar().compareDate(data.eventDate!, toDate: date, toUnitGranularity: .Day)
        if order == NSComparisonResult.OrderedSame{
            return data.numberOfEvent!
        }
    }
    return 0
}

How to add array of event dates on FSCalendar ? Please help , Hi, how to add event and set different color for each event on Swift. thanks. Folks have asked more about working with Event Kit and Swift, so the series continues with this guide on how to create calendar events with Event Kit and Swift! Previous guides in the series include the following: Previous Guides Beginner’s Guide to Event Kit in Swift – Requesting Permission Creating Calendars with Event Kit and Swift Listing Calendar Events with Event Kit and Swift

Try this code,in Objective-C

- (NSInteger)calendar:(FSCalendar *)calendar numberOfEventsForDate:(NSDate*)date
{
    NSString *dateString = [calendar stringFromDate:date format:@"yyyy-MM-dd"];

    if ([_datesWithEvent containsObject:dateString]){
        return 1;
    }
    else{
        NSLog(@"........Events List........");
    }
    return 0;
}

how to add event · Issue #202 · WenchaoD/FSCalendar · GitHub, I'm using fs calendar and i'm trying to set event dots from an array named dates. this array has event dates in it that are saved in string form. so i have to convert  You can call the calendar selectDate with today's date in the button action. like below: NSDate *today = [NSDate date]; [calendar setDate: today]; When you tap the button this will scroll to today with animation and select it.

try these code it will help you

func calendar(_ calendar: FSCalendar, numberOfEventsFor date: Date) -> Int {
            let dateString = self.dateFormatter.string(from: date)
            print(dateString)
            // datesForEvents : array of dates
            if self.datesForEvents.contains(dateString) {
                return 1
            }
            return 0

How to Add events to FSCalendar Swift?, In this tutorial an iCloud Calendar will be created an event will be added Go to the ViewController.swift file and import the EventKit framework. To use FSCalendar in swift, you need to Create Bridge Header first. fileprivate weak var calendar : FSCalendar ! // In loadView or viewDidLoad let calendar = FSCalendar ( frame : CGRect ( x : 0 , y : 0 , width : 320 , height : 300 )) calendar. dataSource = self calendar. delegate = self view. addSubview (calendar) self . calendar = calendar

Add Event to Calendar iOS Tutorial, Disable some future dates selection in FScalendar swift. iosswiftdatedisable​fscalendar How to make a fscalendar event dot show up for date? swift​fscalendar. To use FSCalendar in swift, you need to Create Bridge Header first. fileprivate weak var calendar : FSCalendar ! // In loadView or viewDidLoad let calendar = FSCalendar ( frame : CGRect ( x : 0 , y : 0 , width : 320 , height : 300 )) calendar. dataSource = self calendar. delegate = self view. addSubview (calendar) self . calendar = calendar

FSCalendar - St4k, Or swift. To use FSCalendar in swift, you need to Create Bridge Header first. fileprivate weak var calendar: FSCalendar! // In loadView or viewDidLoad let  Enter Swift as Language and choose Next First a new iCloud calendar need to be created. This can be done on an iOS Device or in OS X. Name the calendar ioscreator.

FSCalendar on CocoaPods.org, Or swift. To use FSCalendar in swift, you need to Create Bridge Header first. private weak var calendar: FSCalendar! // In loadView or  target '<Your Target Name>' do pod 'FSCalendar' end NSCalendarExtension is required to get iOS7 compatibility. Carthage: For iOS8+ github "WenchaoD/FSCalendar" Manually: Drag all files under FSCalendar folder into your project. 👍 Alternatively to give it a test run, simply press command+u in Example-Objc or Example-Swift and launch the

Comments
  • Have got any solution to add events in FSCalendar?
  • Did you figure this out? I dig around in the framework and I only see code for changing colors.
  • How does one ADD an event to a date? Let's say I've got a Date() and I want to mark the date on calendarView as having an event on that date?