Re: stringByTrimmingCharactersInSet (work-around)
Re: stringByTrimmingCharactersInSet (work-around)
- Subject: Re: stringByTrimmingCharactersInSet (work-around)
- From: Jacob Engstrand <email@hidden>
- Date: Sat, 23 Nov 2002 07:09:24 +0100
Hi All.
One work-around is to simply append a space to the string before
trimming. Like this:
value = [value stringByAppendingString: @" "];
value = [value stringByTrimmingCharactersInSet: [NSCharacterSet
whitespaceCharacterSet]];
Not pretty, but the good thing is this code will continue to work after
Apple fixes stringByTrimmingCharactersInSet:.
/jak
Hi All,
NSString *before = @"ab";
NSLog(@"before: '%@'", before);
NSString *after = [before stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"after: '%@'", after);
The above piece of code outputs:
before: 'ab'
after: 'ab'
Which is ok, of course. But changing the first line to:
NSString *before = @"a";
gives the following output:
before: 'a'
after: ''
What gives? Is it me? Am I loosing it? Or is this some bug that
everybody knows about but I?
/jak
_______________________________________________
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.