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

  • Home
  • SEARCH
  • 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

Is the a way to get the NSRange of an NSString in an NSString?
NSString *foo = @ x ; NSRange r = [foo rangeOfCharacterFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSLog(@foo range
I want to count the lines in an NSString in Objective-C. NSInteger lineNum =
NSString *originalString = entriesResultStr; NSRange jarvisRange = [originalString rangeOfString:@favoriteCount]; NSString* substring = [originalString substringToIndex:jarvisRange.location];
Here's what I want to do: NSRange r = NSMakeRange(0,5); id a = [NSMutableArray
I'm having a problem with NSRange. Here is my code: NSRange range = [[[NSHTTPCookie
Ohh, what is wrong with this code !?!?! NSString *s1 = @5 Oct 2010
I'm using an NSRange (a struct) and initializing it like this: @interface MyViewController :
I am developing an app in iPhone I am using an NSRange object in
I am currently using the following algorithm to search on my iPhone app: NSRange

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.