Haneke.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Haneke.swift
  3. // Haneke
  4. //
  5. // Created by Hermes Pique on 9/9/14.
  6. // Copyright (c) 2014 Haneke. All rights reserved.
  7. //
  8. import UIKit
  9. public struct HanekeGlobals {
  10. public static let Domain = "io.haneke"
  11. }
  12. public struct Shared {
  13. public static var imageCache : Cache<UIImage> {
  14. struct Static {
  15. static let name = "shared-images"
  16. static let cache = Cache<UIImage>(name: name)
  17. }
  18. return Static.cache
  19. }
  20. public static var dataCache : Cache<Data> {
  21. struct Static {
  22. static let name = "shared-data"
  23. static let cache = Cache<Data>(name: name)
  24. }
  25. return Static.cache
  26. }
  27. public static var stringCache : Cache<String> {
  28. struct Static {
  29. static let name = "shared-strings"
  30. static let cache = Cache<String>(name: name)
  31. }
  32. return Static.cache
  33. }
  34. public static var JSONCache : Cache<JSONV> {
  35. struct Static {
  36. static let name = "shared-json"
  37. static let cache = Cache<JSONV>(name: name)
  38. }
  39. return Static.cache
  40. }
  41. }
  42. func errorWithCode(_ code: Int, description: String) -> Error {
  43. let userInfo = [NSLocalizedDescriptionKey: description]
  44. return NSError(domain: HanekeGlobals.Domain, code: code, userInfo: userInfo) as Error
  45. }