• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: substringToIndex problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: substringToIndex problem


  • Subject: Re: substringToIndex problem
  • From: Prachi Gauriar <email@hidden>
  • Date: Sat, 31 May 2003 13:49:38 -0500

On Saturday, May 31, 2003, at 01:38 PM, Peter Karlsson wrote:

Dear list!

Can someone please tell me why this does not work? All I want to do is: If the string begins with 'Loop' I want to set the string to Loop.

if ([theValue substringToIndex: 4] == @"Loop")
{
theValue = @"Loop";
}

Peter

You probably need to use [[theValue substringToIndex:4] isEqualToString:@"Loop"]. Else, it's comparing the addresses. On the other hand, why don't you try this:

if ([theValue hasPrefix:@"Loop"]) {
theValue = @"Loop";
}

Make sure you don't have any memory leaks though.

-Prachi
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >substringToIndex problem (From: "Peter Karlsson" <email@hidden>)

  • Prev by Date: showing the about-box at application start up
  • Next by Date: Re: substringToIndex problem
  • Previous by thread: substringToIndex problem
  • Next by thread: Re: substringToIndex problem
  • Index(es):
    • Date
    • Thread