• 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: stringByTrimmingCharactersInSet (work-around)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: stringByTrimmingCharactersInSet (work-around)
      • From: Ali Ozer <email@hidden>
  • Prev by Date: Opening a Contexual Menu on button click?
  • Next by Date: Re: stringByTrimmingCharactersInSet (work-around)
  • Previous by thread: Opening a Contexual Menu on button click?
  • Next by thread: Re: stringByTrimmingCharactersInSet (work-around)
  • Index(es):
    • Date
    • Thread