Re: substringToIndex problem
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.