Last active
September 13, 2018 09:42
-
-
Save dilipiOSDeveloper/c12cb8778feb0d66d0c8122a80963845 to your computer and use it in GitHub Desktop.
Code for checking Selected or Unselected state of CollectionView or TableView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code for checking when cell is selected for CollectionView | |
let cell = collectionView.cellForItem(at: indexPath) | |
if cell?.isSelected == true{ | |
// cell is selected | |
} | |
else{ | |
// cell is not selected | |
} | |
// Code for checking when cell is selected for TableView | |
let cell = catListTable.cellForRow(at: indexPath) | |
if cell?.isSelected == true{ | |
// cell is selected | |
} | |
else{ | |
// cell is not selected | |
} | |
// Filter array of strings | |
import Foundation | |
let arr = ["anuj","amit","tripathi"] | |
let filtered = arr.filter { $0.contains("i") } | |
print(filtered) // Output :- ["amit", "tripathi"] // if we take capital "i" then it will print empty array like [] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment