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 3486836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:04:41+00:00 2026-05-18T11:04:41+00:00

NSRange rangetxt={0,(index-1)}; NSString *tempStr= textBox.text; NSString *tempTextBox=[tempStr substringWithRange:rangetxt]; Hi Everyone, I want to know

  • 0
NSRange rangetxt={0,(index-1)};
NSString *tempStr= textBox.text;
NSString *tempTextBox=[tempStr substringWithRange:rangetxt];

Hi Everyone,

I want to know why my pasted code isn’t working properly, when the compiler passes substringWithRange It hung up and do not assign any value to tempTextBox, Secondly I’ve tried the NSString function substringToIndex as well yet its not working too, My objective is to skip the last character while copying tempStr to tempTextBox.

Regards
MGD

  • 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-18T11:04:42+00:00Added an answer on May 18, 2026 at 11:04 am

    You don’t show the code that’s initialising index. My guess is it’s out of range. Note that substringWithRange raises an NSRangeException if any part of the range lies beyond the end of the receiver.

    Try this:

    NSString *tempStr = textBox.text;
    NSRange rangetxt;
    if ([tempStr length] > 0)
        rangetxt = NSMakeRange(0, [tempStr length] - 1);
    else
        rangetxt = NSMakeRange(0, 0); 
    NSString *tempTextBox = [tempStr substringWithRange:rangetxt];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField.text.length >=8) { return NO; //
Is the a way to get the NSRange of an NSString in an NSString?
NSString *originalString = entriesResultStr; NSRange jarvisRange = [originalString rangeOfString:@favoriteCount]; NSString* substring = [originalString substringToIndex:jarvisRange.location];
I'm having a problem with NSRange. Here is my code: NSRange range = [[[NSHTTPCookie
I knew a instance method of NSString. - (NSRange)rangeOfString:(NSString *)aString My source string looks
NSString *foo = @ x ; NSRange r = [foo rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSLog(@foo range
I am using this function: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { } Inside
I want to count the lines in an NSString in Objective-C. NSInteger lineNum =
How to extract an NSUInteger index from NSRange range = [string rangeOfString: substring] so
I have created a text field to enter an amount of money. I want

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.