title: NSXMLParser:foundCharacters throwing 'Attempt to mutate immutable object with appendString:'
body: <p>I have a problem when parsing an XML feed. There are approximately 15 child nodes per parent node. Currently I am parsing all nodes using stringbytrimmingchartersinset: then  NSCharacterset whitespaceandnewline characterset.
  Like so:</p>
  
  <pre><code>- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
  {
          currentElementValue = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
  }
  </code></pre>
  
  <p>This works great for all but one of the nodes. For this node I want the text to come through as is. I've tried setting up an if statement to treat this particular node differently than the others so I updated to the following.</p>
  
  <pre><code>- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
  {
  
     if ([testingString isEqualToString:@"AdoptionSummary"]) {
         [currentElementValue appendString:string]; //This keeps breaking
          }
      else {
           currentElementValue = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
      }
  </code></pre>
  
  <p>however I'm getting an error. </p>
  
  <blockquote>
    <p>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with appendString:'</p>
  </blockquote>
  
  <p>The error only occurs if I use a combination of stringbytrimmingchartersinset and appendString. However if I use either stringbytrimmingchartersinset or appendString on there own it parses without error.  <code>currentElementValue</code> is an NSMutableString so why is this error being thrown?</p>
  
  <p>I've tried looking at this <a href="https://stackoverflow.com/questions/6414711/nsmutablestring-appendstring-generates-sigabrt-error">NSMutableString appendString generates SIGABRT Error</a>, and this <a href="https://stackoverflow.com/questions/5233178/error-attempt-to-mutate-immutable-object-with-appendstring">error : &#39;Attempt to mutate immutable object with appendString:&#39; --</a> but to no avail.</p>
  
  <p>I would like just 'AdoptionSummary" to append 'as is' while the other 14 are trimmed. What am I doing wrong? Any suggestions?  </p>
  
  <p>Thanks!</p>