I am stumped on this. Here is my scenario. In my Appdelegate, I am creating
I'm not practice with Obj-c so I write my answer in Swift.
supposing birthdays is an array of dates as String
birthdays = [String]()
func addDate() {
birthdays.append("your_new_date")
collectionView.insertItems(at: [IndexPath(item: birthdays.count - 1, section: 0)] )
}
func removeDate() {
if birthdays.count > 0 {
birthdays.removeLast() // use remove(at: Int) instead if u want
collectionView.deleteItems(at: [IndexPath(item: birthdays.count, section: 0)] )
}
}
You should avoid this error:
When the collectionview receives the notification I get the error:
'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'