Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is fairly straight forward setting/getter stuff:</p> <p><strong>XYZArray.h</strong></p> <pre><code>#import &lt;Cocoa/Cocoa.h&gt; @interface XYZArray : NSObject { NSMutableArray *x; NSMutableArray *y; NSMutableArray *z; } -(NSMutableArray*) x; -(NSMutableArray*) y; -(NSMutableArray*) z; -(void) setX:(NSMutableArray*)newArray; -(void) setY:(NSMutableArray*)newArray; -(void) setZ:(NSMutableArray*)newArray; @end </code></pre> <p><strong>XYZArray.m</strong></p> <pre><code>#import "XYZArray.h" @implementation XYZArray - (id)init { if((self = [super init])) { x = [[NSMutableArray alloc] init]; y = [[NSMutableArray alloc] init]; z = [[NSMutableArray alloc] init]; } return self; } - (void) dealloc { [x release]; [y release]; [z release]; [super dealloc]; } -(NSMutableArray*) x { return x; } -(NSMutableArray*) y { return y; } -(NSMutableArray*) z { return z; } -(void) setX:(NSMutableArray*)newArray { [newArray retain]; [x release]; x = newArray; } -(void) setY:(NSMutableArray*)newArray { [newArray retain]; [y release]; y = newArray; } -(void) setZ:(NSMutableArray*)newArray { [newArray retain]; [z release]; z = newArray; } @end </code></pre> <p>Better still, if you are using Objective-C 2.0 you can do all of this with properties and not write any code at all. Read this for an introduction, <a href="http://macdevelopertips.com/objective-c/objective-c-properties-setters-and-dot-syntax.html" rel="nofollow">http://macdevelopertips.com/objective-c/objective-c-properties-setters-and-dot-syntax.html</a>.</p>
 

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