Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using Swift Enums for safer UICollectionViews and UITableViews

278 views

Published on

A good way to let the Swift compiler help you build a rock-solid UICollectionView or UITableView is to manage their layout structure through an enum.

More information and sample code:
https://goto.project-a.com/swift-enums-for-solid-uicollectionview-uitableview/

These slides accompanied my talk at http://swift.berlin/

Published in: Technology
  • Be the first to comment

Using Swift Enums for safer UICollectionViews and UITableViews

  1. 1. Using Swift Enums for safer UICollectionViews and UITableViews swift.berlin meetup November 30, 2015 Ariel Elkin
  2. 2. PROJECT A • Early-stage investor and company builder • Marketplaces, E-commerce, Saas • 20+ companies in our portfolio
  3. 3. ME • iOS Developer in Project A’s Mobile Team • 10+ apps in the App Store • Puts his dishes in the dishwasher
  4. 4. COLLECTION VIEWS ARE COMPLEX • section numbers • item sizes • section count • reuse identifiers • etc…
  5. 5. MANAGING THE LAYOUT STRUCTURE • Typically involves hard-coding integer values
  6. 6. MANAGING THE LAYOUT STRUCTURE • Layout information is fragmented DISADVANTAGES
  7. 7. MANAGING THE LAYOUT STRUCTURE • We have to manually ensure that checks are exhaustive DISADVANTAGES
  8. 8. MANAGING THE LAYOUT STRUCTURE • Error handling not included DISADVANTAGES
  9. 9. THE LAYOUT STRUCTURE? HOW CAN THE COMPILER HELP US WITH
  10. 10. ENUMS
  11. 11. ENUMS • turn the layout structure into a type
  12. 12. NATURAL ERROR-HANDLING ENUMS
  13. 13. EXHAUSTIVITY ENUMS
  14. 14. EXHAUSTIVITY ENUMS
  15. 15. ENUM FUNCTIONS AND PROPERTIES ENUMS
  16. 16. COUNT ENUMS
  17. 17. AUTOCOMPLETION GOODNESS ENUMS
  18. 18. DEMO
  19. 19. FAVOUR DECOUPLING ENUMS
  20. 20. THANK YOU!
  21. 21. QUESTIONS?

×