MTLTransformerErrorHandling.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // MTLTransformerErrorHandling.h
  3. // Mantle
  4. //
  5. // Created by Robert Böhnke on 10/6/13.
  6. // Copyright (c) 2013 GitHub. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /// The domain for errors originating from the MTLTransformerErrorHandling
  10. /// protocol.
  11. ///
  12. /// Transformers conforming to this protocol are expected to use this error
  13. /// domain if the transformation fails.
  14. extern NSString * const MTLTransformerErrorHandlingErrorDomain;
  15. /// Used to indicate that the input value was illegal.
  16. ///
  17. /// Transformers conforming to this protocol are expected to use this error code
  18. /// if the transformation fails due to an invalid input value.
  19. extern const NSInteger MTLTransformerErrorHandlingErrorInvalidInput;
  20. /// Associated with the invalid input value.
  21. ///
  22. /// Transformers conforming to this protocol are expected to associate this key
  23. /// with the invalid input in the userInfo dictionary.
  24. extern NSString * const MTLTransformerErrorHandlingInputValueErrorKey;
  25. /// This protocol can be implemented by NSValueTransformer subclasses to
  26. /// communicate errors that occur during transformation.
  27. @protocol MTLTransformerErrorHandling <NSObject>
  28. @required
  29. /// Transforms a value, returning any error that occurred during transformation.
  30. ///
  31. /// value - The value to transform.
  32. /// success - If not NULL, this will be set to a boolean indicating whether the
  33. /// transformation was successful.
  34. /// error - If not NULL, this may be set to an error that occurs during
  35. /// transforming the value.
  36. ///
  37. /// Returns the result of the transformation which may be nil. Clients should
  38. /// inspect the success parameter to decide how to proceed with the result.
  39. - (id)transformedValue:(id)value success:(BOOL *)success error:(NSError **)error;
  40. @optional
  41. /// Reverse-transforms a value, returning any error that occurred during
  42. /// transformation.
  43. ///
  44. /// Transformers conforming to this protocol are expected to implemented this
  45. /// method if they support reverse transformation.
  46. ///
  47. /// value - The value to transform.
  48. /// success - If not NULL, this will be set to a boolean indicating whether the
  49. /// transformation was successful.
  50. /// error - If not NULL, this may be set to an error that occurs during
  51. /// transforming the value.
  52. ///
  53. /// Returns the result of the reverse transformation which may be nil. Clients
  54. /// should inspect the success parameter to decide how to proceed with the
  55. /// result.
  56. - (id)reverseTransformedValue:(id)value success:(BOOL *)success error:(NSError **)error;
  57. @end