Guest User

Untitled

a guest
Jun 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. var dataArray = NSMutableArray() // dataArray is has a data from Database
  2. var EnabledID = Int()
  3.  
  4. EnabledID = UserDefaults.standard.integer(forKey: "EnabledID")
  5.  
  6. if EnabledID == 0 {
  7.  
  8. EnabledID = 1
  9. UserDefaults.standard.set(1, forKey: "EnabledID")
  10.  
  11. } else {
  12. if EnabledID < dataArray.count {
  13. let index = NSIndexPath(item: EnabledID, section: 0)
  14. self.myCollectionView.scrollToItem(at: index as IndexPath, at: .centeredVertically, animated: true)
  15. }
  16. }
  17.  
  18. var dataArray = NSMutableArray() // dataArray is has a data from Database
  19. var EnabledID = Int()
  20. EnabledID = UserDefaults.standard.integer(forKey: "EnabledID")
  21.  
  22. if EnabledID == 0 {
  23.  
  24. EnabledID = 1
  25. UserDefaults.standard.set(1, forKey: "EnabledID")
  26.  
  27. } else {
  28. If EnabledID < dataArray.count{
  29.  
  30. let indexPath = IndexPath(item: EnabledID, section: 0)
  31.  
  32. if let cell = self.myCollectionView.cellForItem(at: indexPath) as? CollectionViewCell {
  33.  
  34. } else {
  35. print("not able to cast collection view cell class to `CollectionViewCell` ")
  36. }
  37. }
  38. }
Add Comment
Please, Sign In to add comment