Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To access the individual objects in photoArray (eventRow is an instance of EventRow</p> <pre><code>[[eventRow photoArray] objectAtIndex: someIndex]; // I don't like dot notation! </code></pre> <p>or </p> <pre><code>[eventRow.photoArray objectAtIndex: someIndex]; </code></pre> <p>To access the imageArray</p> <pre><code>[[[eventRow photoArray] objectAtIndex: someIndex] imageArray]; </code></pre> <p>or </p> <pre><code>[eventRow.photoArray objectAtIndex: someIndex].imageArray; </code></pre> <p>To get the count of images for that imageArray</p> <pre><code>[[[[eventRow photoArray] objectAtIndex: someIndex] imageArray] count]; </code></pre> <p>or </p> <pre><code>[eventRow.photoArray objectAtIndex: someIndex].imageArray.count; </code></pre> <p>If you want to count all of the images, you need loops but you can use fast enumeration to simplifiy things</p> <pre><code>size_t total = 0; for (PhotoRow* photoRow in [eventRow photoArray]) { total += [[photoRow imageArray] count]; } </code></pre> <p>However, I'd like you to rethink your design a bit. Your exposure of the NSMutableArray in each class breaks encapsulation. Once a caller has got hold of the array, it can modify the internal state of a PhotoRow or an EventRow without the object knowing about it. It would be better not to have the NSMutableArray properties but to add methods to add images and photoRows directly to PhotoRows and EventRows respectively. So, for instance your photoRow class might have the following methods:</p> <pre><code>-(size_t) imageCount; // returns the result of sending -count to the internal array -(NSImage*) imageAtIndex: (size_t) index; // returns the result of sending -objectAtIndex: to the underlying array -(void) addImage: (NSImage*) newImage; // etc </code></pre>
 

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