How to grab everything in a string before a space?
How to grab everything in a string before a space?
- Subject: How to grab everything in a string before a space?
- From: Keith Pritchard <email@hidden>
- Date: Mon, 2 Sep 2002 22:25:36 +0100
Hi all,
So tempting to use plain C here ;-) but I'm trying to learn how to do
it properly soo.....
Have an NSString which looks like "Item1 abcde 12345 y" and all I
need is to get the word before the first space, so, item1 in the
example above.
Been trying the below but getting a crash -> sigsegv or
incompatible pointer type depending how I play with the definitions.....
Whats the easiest way to grab that first word out of the string? Thanks!
NSString *str1;
NSScanner *myScanner=[NSScanner scannerWithString:myString];
[myScanner scanUpToString:@" " intoString:str1];
Having read the docs a little more, I'm getting the feeling that I may
need to tell NSScanner not to ignore spaces (does it really default to
ignoring spaces/newlines! eek?!)
Any hints appreciated,
Cheers,
Keith
_______________________________________________
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.