NSObject+A2DynamicDelegate.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // NSObject+A2DynamicDelegate.h
  3. // BlocksKit
  4. //
  5. #import "A2DynamicDelegate.h"
  6. #import <Foundation/Foundation.h>
  7. /** The A2DynamicDelegate category to NSObject provides the primary interface
  8. by which dynamic delegates are generated for a given object. */
  9. @interface NSObject (A2DynamicDelegate)
  10. /** Creates or gets a dynamic data source for the reciever.
  11. A2DynamicDelegate assumes a protocol name `FooBarDataSource`
  12. for instances of class `FooBar`. The object is given a strong
  13. attachment to the reciever, and is automatically deallocated
  14. when the reciever is released.
  15. If the user implements a `A2DynamicFooBarDataSource` subclass
  16. of A2DynamicDelegate, its implementation of any method
  17. will be used over the block. If the block needs to be used,
  18. it can be called from within the custom
  19. implementation using blockImplementationForMethod:.
  20. @see <A2DynamicDelegate>blockImplementationForMethod:
  21. @return A dynamic data source.
  22. */
  23. - (id)bk_dynamicDataSource;
  24. /** Creates or gets a dynamic delegate for the reciever.
  25. A2DynamicDelegate assumes a protocol name `FooBarDelegate`
  26. for instances of class `FooBar`. The object is given a strong
  27. attachment to the reciever, and is automatically deallocated
  28. when the reciever is released.
  29. If the user implements a `A2DynamicFooBarDelegate` subclass
  30. of A2DynamicDelegate, its implementation of any method
  31. will be used over the block. If the block needs to be used,
  32. it can be called from within the custom
  33. implementation using blockImplementationForMethod:.
  34. @see <A2DynamicDelegate>blockImplementationForMethod:
  35. @return A dynamic delegate.
  36. */
  37. - (id)bk_dynamicDelegate;
  38. /** Creates or gets a dynamic protocol implementation for
  39. the reciever. The designated initializer.
  40. The object is given a strong attachment to the reciever,
  41. and is automatically deallocated when the reciever is released.
  42. If the user implements a subclass of A2DynamicDelegate prepended
  43. with `A2Dynamic`, such as `A2DynamicFooProvider`, its
  44. implementation of any method will be used over the block.
  45. If the block needs to be used, it can be called from within the
  46. custom implementation using blockImplementationForMethod:.
  47. @param protocol A custom protocol.
  48. @return A dynamic protocol implementation.
  49. @see <A2DynamicDelegate>blockImplementationForMethod:
  50. */
  51. - (id)bk_dynamicDelegateForProtocol:(Protocol *)protocol;
  52. @end