Re: stringByTrimmingCharactersInSet (revisited)
Re: stringByTrimmingCharactersInSet (revisited)
- Subject: Re: stringByTrimmingCharactersInSet (revisited)
- From: Lorenzo <email@hidden>
- Date: Sat, 23 Aug 2003 18:48:09 +0200
Hi,
you can put it in single line of code too.
if([myString characterAtIndex:0] == '"' &&
[myString characterAtIndex:[myString length]-1] == '"')
{
myString = [myString substringWithRange:
NSMakeRange(1, [myString length]-2)];
}
Best Regards
--
Lorenzo
email: email@hidden
>
From: Brad Peterson <email@hidden>
>
Date: Sat, 23 Aug 2003 11:16:26 +0000
>
To: email@hidden
>
Subject: stringByTrimmingCharactersInSet (revisited)
>
>
Hi all,
>
>
I know there have been a number of posts over the years about this subject,
>
but I've run into an interesting new twist (at least, I didn't see it in the
>
archives) that I thought I'd share/open for comments...
>
>
I've got a string (ip address) which may (or may not) arrive in my app
>
quoted. (That is, "102.111.34.4" where the quote marks are actually part of
>
the string data I'll receive.)
>
>
So that I can use the ip address elsewhere, I wanted to do a
>
stringByTrimmingCharactersInSet always without needing to test for the
>
presence of the quotes.
>
>
However, the compiler won't let me use the escaped quote (\") as below:
>
>
ip = [ip stringByTrimmingCharactersInSet:[NSCharacterSet
>
characterSetWithCharactersInString:@"\""]];
>
>
Any thoughts? I'm open to suggestions on either how to rewrite this line or
>
achieve the same results other ways...
>
>
Brad
_______________________________________________
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.