title: Replace character in string
body: <p>I have a <code>NSMutableString</code> <code>@"hello"</code>. I'd like to replace the character at the second position, 'e' with 'a' so that it reads <code>@"hallo"</code>. How do I do that?</p>
  
  <p>I have tried this to implement a Shift Cipher, but it throws an <code>IndexOutBoundsException</code></p>
  
  <pre><code>- (NSString*)encode:(NSString*)original withShift:(int)shift {
  
      NSMutableString* encoded = [NSMutableString stringWithString:original];
      for (int i=0; i &lt; [encoded length]; i++) {
          char oriChar = [encoded characterAtIndex:i];
          if (oriChar == ' ') {
              continue;
          }
          char encChar = ((oriChar - LETTER_POS) + shift) % ALPHABET_LENGTH + LETTER_POS;
  
          NSRange range = {i, i};
          [encoded replaceCharactersInRange:range withString:[NSString stringWithUTF8String:&amp;encChar]];
  
      }
      return encoded;
  
  }
  </code></pre>