Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var dataArray = NSMutableArray() // dataArray is has a data from Database
- var EnabledID = Int()
- EnabledID = UserDefaults.standard.integer(forKey: "EnabledID")
- if EnabledID == 0 {
- EnabledID = 1
- UserDefaults.standard.set(1, forKey: "EnabledID")
- } else {
- if EnabledID < dataArray.count {
- let index = NSIndexPath(item: EnabledID, section: 0)
- self.myCollectionView.scrollToItem(at: index as IndexPath, at: .centeredVertically, animated: true)
- }
- }
- var dataArray = NSMutableArray() // dataArray is has a data from Database
- var EnabledID = Int()
- EnabledID = UserDefaults.standard.integer(forKey: "EnabledID")
- if EnabledID == 0 {
- EnabledID = 1
- UserDefaults.standard.set(1, forKey: "EnabledID")
- } else {
- If EnabledID < dataArray.count{
- let indexPath = IndexPath(item: EnabledID, section: 0)
- if let cell = self.myCollectionView.cellForItem(at: indexPath) as? CollectionViewCell {
- } else {
- print("not able to cast collection view cell class to `CollectionViewCell` ")
- }
- }
- }
Add Comment
Please, Sign In to add comment