title: Swapping Objects in objective c
body: <p>I am trying to swap two objects upon a button action, but I can't get it to work. It's swapping on first time, but next time when I click on the button, it crashes with EXC_BAD_ACCESS.</p>
  
  <p>Here's the code</p>
  
  <pre><code>-(IBAction)swapLocation
  {
      CCLocDTO *tempDto = searchDTO.toDTO;
      searchDTO.toDTO = searchDTO.fromDTO;
      searchDTO.fromDTO = tempDto;
  
      NSLog(@"From Location is %@",searchDTO.fromDTO.streetAddress); //it becomes empty on next button click
      NSLog(@"To Location is %@",searchDTO.toDTO.streetAddress);
      NSLog(@"From Special Location is %@",searchDTO.fromSpecialDTO.locationName);
      NSLog(@"To Special Location is %@",searchDTO.toSpecialDTO.locationName);
  
      [self.tableView reloadData];
  
  }
  </code></pre>
  
  <p>I am assigning fromDTO and toDTO in Search DTO(searchDTO).</p>