title: Reversing a string in iOS
body: <p>I am writing code which should reverse a string. When I run the following code it throws an error:</p>
  
  <pre><code>- (NSString*) reversingName:(NSString *)myNameText
  {
     NSString *result;
     int len = [myNameText length];
     NSMutableString *reverseName = [[NSMutableString alloc] initWithCapacity:len];
     for(int i=len;i&gt;0;i--)
     {
       [reverseName appendFormat:[NSString stringWithFormat:@"%c",[myNameText characterAtIndex:i]]];
     }
     result = reverseName;
     return result;
  }
  </code></pre>