Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat equivalent code is synthesized for a declared property?
    primarykey
    data
    text
    <p>How exactly getter and setter methods body looks like after they have been automatically synthesized ?</p> <p>From official documentation I found so far only recommended implementation techniques, however no word about which of them used by compiler during synthesizing process: <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAccessorMethods.html#//apple_ref/doc/uid/TP40003539-SW5" rel="nofollow">http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAccessorMethods.html#//apple_ref/doc/uid/TP40003539-SW5</a></p> <p>Some techniques recommends implementations containing <code>autorelease</code> message, which is not quite secure for multithreaded programming. I'm just wonder if auto-generated code follows to some of the proposed implementations.</p> <hr> <p>For example:</p> <p><strong>.h</strong></p> <pre><code>@interface AClass: NSObject{} @property (nonatomic, retain) AnotherClass *aProp; @end </code></pre> <p><strong>.m</strong></p> <pre><code>@implementation AClass @synthesize aProp -(id) init { if ((self = [super init])) { self.aProp = [[AnotherClass alloc] init]; // setter invocation } return self; } -(AnotherClass *) aMethod { return self.aProp; // getter invocation } @end </code></pre> <p>What are equivalent accessors code snippets for <code>aProp</code> generated by compiler ?</p> <pre><code>-(AnotherClass *) aProp { // getter body } -(void) setAProp: (AnotherClass *) { // setter body } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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