title: Making an array of Objects in Objective-C.
body: <p>Been playing around with XCode for about 2 weeks now, and reading about MVC a bit. I have a problem trying to connect the Model to the Controller because I find it hard to get my head around arrays. I can handle simple arrays when i programmed some in Java but I'm quiet intimidated by the Obj-C <code>NSArrays</code> I see. </p>
  
  <p>If somebody would be so kind to show me some simple calls on an array of objects i would be eternally grateful.</p>
  
  <p>My model:</p>
  
  <p>Person.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface Person : NSObject 
  {
  NSString *name;
  NSNumber *age;
  }
  
  @property(nonatomic, retain) NSString *name;
  @property(nonatomic, retain) NSNumber *age;
  
  @end
  </code></pre>
  
  <p>Person.m </p>
  
  <pre><code>#import "Person.h"
  @implementation Person
  @synthesize name;
  @synthesize age;
  @end
  </code></pre>
  
  <p>I've kept if very simple while I try and learn.</p>
  
  <p>Now my Controller class. What i want to do is create an array of 40 'Person' objects. But i don't know the correct way to put that in code in Obj C.</p>
  
  <p>Controller.h</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  @class Person;
  @interface Controller : NSObject 
  {
  Person *person;
  }
  @property(nonatomic, retain) Person *person;
  
  -(void) doSomeWork;
  
  @end
  </code></pre>
  
  <p>Controller.m</p>
  
  <pre><code>#import "Controller.h"
  #import "Person.h"
  
  @implementation Controller
  
  @synthesize person;
  
  
  -(IBAction)doSomeWork
  {
  // I guess here is where i should create my array of 40 person objects
  }
  
  @end
  </code></pre>
  
  <p>My problem is in how to declare the array of person objects of size 40.
  And then how to access the array to read and write to it.</p>
  
  <p>Thanks in advance for reading my post.</p>