title: Implementing NSCopying
body: <p>I've read the <code>NSCopying</code> docs but I am still very unsure about how to implement what is required.</p>
  
  <p>My class <code>Vendor</code>:</p>
  
  <pre><code>@interface Vendor : NSObject 
  {
      NSString        *vendorID;
      NSMutableArray  *availableCars;
      BOOL            atAirport;
  }
  
  @property (nonatomic, copy) NSString *vendorID;
  @property (nonatomic, retain) NSMutableArray *availableCars;
  @property (nonatomic, assign) BOOL atAirport;
  
  - (id)initFromVehVendorAvailsDictionary:(NSDictionary *)vehVendorAvails;
  
  @end
  </code></pre>
  
  <p>The <code>Vendor</code> class has an array of objects called <code>Car</code>. </p>
  
  <p>My <code>Car</code> object:</p>
  
  <pre><code>@interface Car : NSObject 
  {
      BOOL            isAvailable;
      NSString        *transmissionType;
      NSMutableArray  *vehicleCharges; 
      NSMutableArray  *fees; 
  }
  
  @property (nonatomic, assign) BOOL isAvailable;
  @property (nonatomic, copy) NSString *transmissionType;
  @property (nonatomic, retain) NSMutableArray *vehicleCharges;
  @property (nonatomic, retain) NSMutableArray *fees;
  
  - (id) initFromVehicleDictionary:(NSDictionary *)vehicleDictionary;
  
  @end
  </code></pre>
  
  <p>So, <code>Vendor</code> holds an array of <code>Car</code> objects. <code>Car</code> holds 2 arrays of other custom objects. </p>
  
  <p>Both <code>Vendor</code> and <code>Car</code> are init from a dictionary. I'll add one of these methods, they may or may not be relevant.</p>
  
  <pre><code>-(id)initFromVehVendorAvailsDictionary:(NSDictionary *)vehVendorAvails {
  
      self.vendorCode      = [[vehVendorAvails objectForKey:@"Vendor"] 
                             objectForKey:@"@Code"];
  
      self.vendorName      = [[vehVendorAvails objectForKey:@"Vendor"] 
                             objectForKey:@"@CompanyShortName"];
  
      self.vendorDivision  = [[vehVendorAvails objectForKey:@"Vendor"]   
                             objectForKey:@"@Division"];
  
      self.locationCode    = [[[vehVendorAvails objectForKey:@"Info"] 
                             objectForKey:@"LocationDetails"] 
                             objectForKey:@"@Code"];
  
      self.atAirport       = [[[[vehVendorAvails objectForKey:@"Info"] 
                             objectForKey:@"LocationDetails"] 
                             objectForKey:@"@AtAirport"] boolValue];
  
      self.venLocationName = [[[vehVendorAvails objectForKey:@"Info"] 
                             objectForKey:@"LocationDetails"] 
                             objectForKey:@"@Name"];
  
      self.venAddress      = [[[[vehVendorAvails objectForKey:@"Info"] 
                             objectForKey:@"LocationDetails"] 
                             objectForKey:@"Address"] 
                             objectForKey:@"AddressLine"];
  
      self.venCountryCode  = [[[[[vehVendorAvails objectForKey:@"Info"]  
                             objectForKey:@"LocationDetails"] 
                             objectForKey:@"Address"] 
                             objectForKey:@"CountryName"]
                             objectForKey:@"@Code"];
  
      self.venPhone        = [[[[vehVendorAvails objectForKey:@"Info"]  
                             objectForKey:@"LocationDetails"]        
                             objectForKey:@"Telephone"] 
                             objectForKey:@"@PhoneNumber"];
  
      availableCars        = [[NSMutableArray alloc] init];
  
      NSMutableArray *cars = (NSMutableArray *)[vehVendorAvails objectForKey:@"VehAvails"];
  
      for (int i = 0; i &lt; [cars count]; i++) {
  
          Car *car = [[Car alloc] initFromVehicleDictionary:[cars objectAtIndex:i]];
          [availableCars addObject:car];
          [car release];
      }
  
      self.venLogo = [[[vehVendorAvails objectForKey:@"Info"] 
                     objectForKey:@"TPA_Extensions"] 
                     objectForKey:@"VendorPictureURL"];
  
      return self;
  }
  </code></pre>
  
  <p>So to summarize the scary problem.</p>
  
  <p>I need to copy an array of <code>Vendor</code> objects. I believe I need to implement the <code>NSCopying</code> protocol on <code>Vendor</code>, which may mean I need to implement it also on <code>Car</code> since <code>Vendor</code> holds an array of <code>Car</code>s. That means I also need to implement it on the classes that are held in the 2 arrays belonging to the <code>Car</code> object.</p>
  
  <p>I'd really appreciate it if I could get some guidance on implementing <code>NSCopying</code> protocol on <code>Vendor</code>, I can't find any tutorials on this anywhere.</p>