ipraba / EPCalendarPicker

Colourful calendar for iOS written in Swift
MIT License
347 stars 73 forks source link

modify selected dates array #14

Open antons81 opened 8 years ago

antons81 commented 8 years ago

Hi, the issues is, while I am creating calendar controller and providing an array with already selected dates. Than I need to remove some dates from this array and save again calendar with new array of dates. But you not removing no needed dates from current array and adding another the same 2 dates and not modifying current array

this is array from delegate I have provided these dates 2016-04-10 21:00:00 +0000, 2016-04-12 21:00:00 +0000 than clicked again to remove it and get this one [2016-04-10 21:00:00 +0000, 2016-04-12 21:00:00 +0000, 2016-04-10 21:00:00 +0000, 2016-04-12 21:00:00 +0000]

ipraba commented 8 years ago

I quite cant understand your issue. Can you please elaborate more How are you removing the dates? Can you provide some code?

antons81 commented 8 years ago

I mean by that, that you are not modifying current array while selecting dates. I create EPCalendar Picker with predefined dates array. Than I need edit dates and remove some dates and add new dates than click on done and delegate logs tell me that old dates still in the array + new dates I selected

dylankbuckley commented 7 years ago

This is what I think you are trying to do:

  1. Initialise calendar with an array of provided dates
  2. You then open the calendar and select / deselect dates
  3. On closing the calendar you call the delegate method: @objc optional func epCalendarPicker(_: EPCalendarPicker, didSelectMultipleDate dates : [Date])
  4. In theory, if I understand you correctly you now have two arrays of Date objects and you just want to know what ones have been removed and which ones have been added?
  5. You could loop through items in new array and use the contains() function on the initial array to see if they are in there or not. If they aren't then they are added, and doing it the other way round will give you the dates that have been removed.