• 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
NSString stringByTrimmingCharactersInSet: strangeness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSString stringByTrimmingCharactersInSet: strangeness


  • Subject: NSString stringByTrimmingCharactersInSet: strangeness
  • From: Gus Mueller <email@hidden>
  • Date: Tue, 1 Jul 2003 16:40:22 -0700

I just noticed something that I thought was odd about the
stringByTrimmingCharactersInSet method in NSString-

I've got the following code (sorry for the formatting):

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"trimed is: '%@'",
[@"s" stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]]
);
[pool release];
return 0;
}

and it gives me the output:

2003-07-01 18:35:31.816 strtest[9480] trimed is: ''

... that seems a little weird- I figured it would just return the "s"
again, not an empty string.. I read the docs on
stringByTrimmingCharactersInSet and it suggests that what I'm thinking
is correct, but the output isn't. If I use the string "ss", everything
works fine, but a variation in the single s (" s") isn't.

Can anybody shed some light on this? Do I misunderstand this api?

thanks,

-gus

--
"Christmas means carnage!" -- Ferdinand, the duck
_______________________________________________
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: NSString stringByTrimmingCharactersInSet: strangeness
      • From: Gus Mueller <email@hidden>
  • Prev by Date: Re: Strong language about Cocoa and Qt.
  • Next by Date: Re: Strong language about Cocoa and Qt.
  • Previous by thread: Re: IOKit Power Manager Help
  • Next by thread: Re: NSString stringByTrimmingCharactersInSet: strangeness
  • Index(es):
    • Date
    • Thread