iPhone: Make categories defined inside libraries actually work


/ Published in: Objective C
Save to your folder(s)

There seems to be an bugrelated to static libraries with an implementation file that contains ONLY implementations of category methods. The FIX_CATEGORY_BUG macro basically just expands to define an interface and implementation of that interface with no methods, just to force something into the .m file that isn't a category.


Copy this code and paste it in your HTML
  1. //CategoryBugHack.h
  2. #define FIX_CATEGORY_BUG(name) @interface FIX_CATEGORY_BUG##name @end @implementation FIX_CATEGORY_BUG##name @end
  3. Then the category .h/.m ...
  4.  
  5. //NSStringCategory.h
  6. @interface NSString (MyAdditions)
  7. // etc, etc
  8. @end
  9.  
  10. //NSStringCategory.m
  11. #import "CategoryBugHack.h"
  12. FIX_CATEGORY_BUG(NSString_MyAdditions)
  13. @implementation NSString (MyAdditions)
  14. // etc, etc
  15. @end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.