title: Objective-C, set and get variables in class object which is stored in NSArray
body: <p>I am trying to write my own class storing data about libraries and then store each object in an NSArray.</p>
  <p>My interface:</p>
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface LibraryInfo : NSObject
  {
  
  NSString* name;
  NSString* address;
  NSString* link;
  NSString* coordinates;
  
  }
  
  - (NSString*) getName;
  - (NSString*) getAddress;
  - (NSString*) getLink;
  - (NSString*) getCoordinates;
  
  - (void) setName: (NSString*)input;
  - (void) setAddress: (NSString*)input;
  - (void) setLink: (NSString*)input;
  - (void) setCoordinates: (NSString*)input;
  
  @end
  </code></pre>
  <p>My implementation:</p>
  <pre><code>#import &quot;LibraryInfo.h&quot;
  
  @implementation LibraryInfo
  
  - (void) setName: (NSString*)input
  {
  name = input;
  }
  
  - (void) setAddress: (NSString*)input
  {
  address = input;
  }
  
  - (void) setLink: (NSString*)input
  {
  link = input;
  }
  
  - (void) setCoordinates: (NSString*)input
  {
  coordinates = input;
  }
  
  - (NSString*) getName {
  return name;
  }
  
  - (NSString*) getAddress {
  return address;
  }
  
  - (NSString*) getLink {
  return link;
  }
  
  - (NSString*) getCoordinates {
  return coordinates;
  }
  
  @end
  </code></pre>
  <p>I write and store each object in the NSArray, like so:</p>
  <pre><code>LibraryInfo *library = [[LibraryInfo alloc] init];
  [library setName:( ( name != nil &amp;&amp; name.length &gt; 0 ) ? name : @&quot;No Name&quot; )];
  [library setAddress:( ( address != nil &amp;&amp; address.length &gt; 0 ) ? address : @&quot;No Address&quot; )];
  [library setLink:( ( link != nil &amp;&amp; link.length &gt; 0 ) ? link : @&quot;No Link&quot; )];
  [library setCoordinates:( ( coordinate != nil &amp;&amp; coordinate.length &gt; 0 ) ? coordinate : @&quot;No Coordinates&quot; )];
      
  [libraries addObject: library];
  </code></pre>
  <p>Where 'libraries' is an NSArray.</p>
  <p>Then I try to read the values like so:</p>
  <pre><code>cell.textLabel.text = [[ libraries objectAtIndex:indexPath.row ] getName ];
  cell.detailTextLabel.text = [[ libraries objectAtIndex:indexPath.row ] getAddress ];
  </code></pre>
  <p>I think it may be something to do with the setting of the values, or maybe they are not properly stored or retained, but I get the following error and a marker by my 'setName' method<br />
  when the App 'crashes' and pauses:</p>
  <pre><code>self    LibraryInfo *const  0x068a1760
  input   NSString *  0x068a3550
  name    NSString *  0x00000000
  </code></pre>
  <p>How do I fix this? I'm using Xcode 4.3 so no releases/retains needed.</p>