I have used UICollectionView Cells for my app. It is populated by Arrays.
I have two CollectionView Sections. Section '0' & Section '1' has it's own cells populated with arrays.
There are multiple cells in section 1.
I want to enable user to rearrange cells within section 1. User should not be able to move cell from section 1 to section 0.
I am using following code but It is giving me errors...
I tried searching on the web but I didn't got the answer so I am posting it here for help...
override func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
let sourceSection = sourceIndexPath.section
let destSection = destinationIndexPath.section
if (sourceSection destSection) {
let tempInputDataArray = inputDataArray.remove(at: sourceIndexPath.item)
inputDataArray.insert(tempInputDataArray, at: destinationIndexPath.item)
UserDefaults.standard.set(inputDataArray, forKey: "KeyForInputDataArray")
for element in inputDataArray {
print(element)
}
} else {
}
}
7
0
2k