Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // This goes in the header that users of your framework/static lib can use:
  2.  
  3. @interface MyPublicClass : NSObject
  4. {
  5.     struct MyPublicClassIVars    *ivars;
  6. }
  7.  
  8. @property (assign) int myInt;
  9.  
  10. @end
  11.  
  12.  
  13. // ----------
  14. // This goes in the implementation file that gets compiled into the library and thus never gets seen by clients:
  15.  
  16. struct MyPublicClassIVars
  17. {
  18.     int myInt;
  19. };
  20.  
  21.  
  22. @implementation MyPublicClass
  23.  
  24. -(id)    init
  25. {
  26.     if(( self = [super init] ))
  27.     {
  28.         ivars = calloc( 1, sizeof(struct MyPublicClassIVars) );
  29.     }
  30.     return self;
  31. }
  32.  
  33.  
  34. -(void)    dealloc
  35. {
  36.     free( ivars );
  37.     [super dealloc];
  38. }
  39.  
  40.  
  41. -(void)    setMyInt: (int)theInt
  42. {
  43.     ivars->myInt = theInt;
  44. }
  45.  
  46.  
  47. -(int)    myInt
  48. {
  49.     return ivars->myInt;
  50. }
  51.  
  52. @end