Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't use <code>@synthesize</code> with a category.</p> <p>You <em>can</em> do this with an class extension (a.k.a. anonymous category), which is just a category without a name whose methods must be implemented in the main <code>@implementation</code> block for that class. For your code, just change "(Private)" to "()" and use <code>@synthesize</code> in the main <code>@implementation</code> block along with the rest of your code for that class.</p> <p>See <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocCategories.html" rel="noreferrer">the Apple docs on extensions</a> for more about that. (Apparently this is new in Mac OS 10.5.)</p> <p>EDIT: An example:</p> <pre><code>// Main interface (in .h) @interface Foo : NSObject - (void)bar; @end // Private interface (in .m, or private .h) @interface Foo () @property (nonatomic, copy) NSString *myData; @end @implementation Foo @synthesize myData; // only needed for Xcode 4.3 and earlier - (void)bar { ... } @end </code></pre> <p>Another solution, which is much more work, is to use <code>objc_setAssociatedObject</code> and <code>objc_getAssociatedObject</code> to fake additional instance variables. In this case, you could declare these as properties, and implement the setters and getters yourself using the objc_* runtime methods above. For more detail on those functions, see <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html" rel="noreferrer">the Apple docs on Objective-C runtime</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload