Krutarth Patel
Krutarth Patel

Reputation: 3455

How to remove Section according to indexpath in CollectionView in swift?

my functionality is when i remove on close button section and data also be removed from indexpath.

i have taken UICollelctionReusableView for Section.

section count is according to array of number of Apple Data.

i have attached image

Header

and data is attached to header like header and one row.

i want to remove section and row when i tap on close button. can anyone help me to findout solution?

sample code

  var index:NSIndexPath = sender.tag
    array.removeAtIndex(indexPath.row())
    self.coll.deleteItemsAtIndexPaths([sender.tag])

Upvotes: 1

Views: 3966

Answers (1)

Iree
Iree

Reputation: 358

If you want to remove the entire section, it should be something like this:

let section = sender.tag
array.removeAtIndex(section)
collectionView.deleteSections(NSIndexSet(index: section))

Given that all the section data is inside array[section].

Upvotes: 6

Related Questions