Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:49:00+00:00 2026-05-23T21:49:00+00:00

I have been googling so much on how to do this, but how would

  • 0

I have been googling so much on how to do this, but how would I reverse a NSString? Ex:hi would become: ih

I am looking for the easiest way to do this.

Thanks!

@Vince I made this method:

- (IBAction)doneKeyboard {

// first retrieve the text of textField1
NSString *myString = field1.text;
NSMutableString *reversedString = [NSMutableString string];
NSUInteger charIndex = 0;
while(myString && charIndex < [myString length]) {
    NSRange subStrRange = NSMakeRange(charIndex, 1);
    [reversedString appendString:[myString substringWithRange:subStrRange]];
    charIndex++;
}
// reversedString is reversed, or empty if myString was nil
field2.text = reversedString;
}

I hooked up that method to textfield1’s didendonexit. When I click the done button, it doesn’t reverse the text, the UILabel just shows the UITextField’s text that I entered. What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:49:01+00:00Added an answer on May 23, 2026 at 9:49 pm

    Write a simple loop to do that:

    // myString is "hi"
    NSMutableString *reversedString = [NSMutableString string];
    NSInteger charIndex = [myString length];
    while (charIndex > 0) {
        charIndex--;
        NSRange subStrRange = NSMakeRange(charIndex, 1);
        [reversedString appendString:[myString substringWithRange:subStrRange]];
    }
    NSLog(@"%@", reversedString); // outputs "ih"
    

    In your case:

    // first retrieve the text of textField1
    NSString *myString = textField1.text;
    NSMutableString *reversedString = [NSMutableString string];
    NSInteger charIndex = [myString length];
    while (myString && charIndex > 0) {
        charIndex--;
        NSRange subStrRange = NSMakeRange(charIndex, 1);
        [reversedString appendString:[myString substringWithRange:subStrRange]];
    }
    // reversedString is reversed, or empty if myString was nil
    textField2.text = reversedString;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been googling for hours looking for something to handle my situation. I
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have done a number of google searches on this topic, but haven't been
I have been googling but so far results found not fully match to my
I've done some Googling and searching on SO, but I have not been able
After much googling I have been wondering what the benefits/differences are between mysql and
I have been Googling a problem that I have with trying to integrate the
So I have been Googling and I am quite sure my problem emerge from
Have been working on this question for a couple hours and have come close
Have been searching how to convert a dictionary to a string. But the results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.