title: iPhone - Objective-C - Memory Leak with initWithArray
body: <p>I am using the code below to set my two <code>NSArray</code> ivars:</p>
  
  <p>The issue is, I keep getting a memory leak on the following lines:</p>
  
  <pre><code>followingFriendsArray = [[NSArray alloc] initWithArray:friend.Following];
  followerFriendsArray = [[NSArray alloc] initWithArray:friend.Followers];
  </code></pre>
  
  <p>Is this not the correct way to set ivars from an existing <code>NSArray</code> of items? Any help would be appreciated. I've also tried to <code>autorelease</code> the above two lines, but when I actually access them in another method I get an error that they've already been released.</p>
  
  <p>I have included my Interface and Implementation code below:</p>
  
  <p>Interface .h:</p>
  
  <pre><code>NSArray *followingFriendsArray;
  NSArray *followerFriendsArray;
  
  @property (nonatomic, retain) NSArray *followingFriendsArray;
  @property (nonatomic, retain) NSArray *followerFriendsArray;
  </code></pre>
  
  <p>Implementation .m:</p>
  
  <pre><code>- (void)handlerGetFollowingInformation:(id)value {
      BOOL success = [Utility checkWebServiceErrors:value controller:self.navigationController];
  
      if (success) {
          Friend *friend = (Friend *)value;
  
          followingFriendsArray = [[NSArray alloc] initWithArray:friend.Following];
          followerFriendsArray = [[NSArray alloc] initWithArray:friend.Followers];
      }
  }
  </code></pre>
  
  <p>This is how I need to access the arrays:</p>
  
  <pre><code>- (void)followersButtonTapped:(id)sender {
      FollowingVC *fvc = [[FollowingVC alloc] initWithNibName:@"FollowingViewController" bundle:nil];
  
      fvc.friends = followerFriendsArray;
  
      [self.navigationController pushViewController:fvc animated:YES];
      [fvc release];
  }
  </code></pre>
  
  <p>I release my two ivars in the following way as per usual:</p>
  
  <pre><code>- (void)viewDidUnload {
      self.followingFriendsArray = nil;
      self.followerFriendsArray = nil;
      [super viewDidUnload];
  }
  
  - (void)dealloc {
      [followingFriendsArray release];
      [followerFriendsArray release];
      [super dealloc];
  }
  </code></pre>
  
  <p>I mean the code works just fine, it's just that I'm concerned about said memory leaks when I run the "Leaks" performance tool.</p>