Guest User

Untitled

a guest
Apr 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. //This is model setup, the important stuff is at the bottom.
  2.  
  3. enum ClothingColor {
  4. case red, green, blue, purple, silver
  5. }
  6.  
  7. enum ClothingPattern {
  8. case solid, polkadots, checks, herringbone
  9. }
  10.  
  11. enum ClothingType {
  12. case pants, dress, skirt, shoes, bracelet
  13. }
  14.  
  15. enum ClothingFit {
  16. case slim, normal, loose
  17. }
  18.  
  19. struct ClothingItem {
  20. let id: String
  21. let color: ClothingColor
  22. let secondaryColor: ClothingColor
  23. let pattern: ClothingPattern
  24. let type: ClothingType
  25. let fit: ClothingFit
  26. }
  27.  
  28. //Sample service class we provide.
  29. protocol DataService_Protocol {
  30. func data(completion: @escaping ([ClothingItem]) -> Void)
  31. }
  32.  
  33. class ClothingDataService: DataService_Protocol {
  34. func data(completion: @escaping ([ClothingItem]) -> Void) {
  35. let clothingItems = [ClothingItem(id: "123", color: .red, secondaryColor: .blue, pattern: .checks, type: .pants, fit: .normal),
  36. ClothingItem(id: "543", color: .blue, secondaryColor: .silver, pattern: .checks, type: .pants, fit: .normal)]
  37. completion(clothingItems)
  38. }
  39. }
  40.  
  41. /**
  42. We'd like you to take a list of items, filter out all items for "total"
  43. avoids, and for items with "partial" avoids, sort those to the end of the list and display in the provided table view.
  44.  
  45. At minimum candidate should use a view controller, a table view, and write some type of filtering logic.
  46.  
  47. Follow ups:
  48. 1. Error handling (talk about different ways to do it and implement one) -> Result<T>, (onSuccess:, @escaping T onError: @escaping Error), Promises...
  49. 2. Multithreading with GCD (the data source executes off the main thread but keep UI manipulation on the main thread).
  50. 3. Testing, modify for dependency injection -> Shows they understand protocols.
  51. **/
Add Comment
Please, Sign In to add comment