Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. @interface MyClass(CategoryA)
  2.  
  3. -(void)specificCategoryA;
  4.  
  5. @end
  6.  
  7.  
  8. @interface MyClass(CategoryB)
  9.  
  10. -(void)specificCategoryB;
  11.  
  12. @end
  13.  
  14. @implementation MyClass
  15.  
  16. -(void)utilityMethod {
  17.  
  18. // choose one of the two...
  19. // -(void)specificCategoryB;
  20. // -(void)specificCategoryA;
  21.  
  22. }
  23.  
  24. @end
  25.  
  26. #if some-constant-condition
  27. [mc specificCategoryA];
  28. #else
  29. [mc specificCategoryB];
  30. #endif
  31.  
  32. -(void)utilityMethod
  33. {
  34. [super utilityMethod];
  35. // subclass specific code.
  36. }
  37.  
  38. if ([object respondsToSelector:@selector(specificCategoryA)]) {
  39. [object specificCategoryA];
  40. }
  41. else if ([object respondsToSelector:@selector(specificCategoryB)]) {
  42. [object specificCategoryB];
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement