FROM : Jonathan Jackel
DATE : Mon Nov 25 04:12:30 2002
on 11/24/02 9:03 PM, Koen van der Drift at <email_removed> wrote:
>> Unfortunately, this doesn't work. Starting with the string
>> "QWERTYASDFGZXCVBNM" I get three single charcters as result: "A" "C" and "B",
>> instead of "QWERTYA", "SDFGZXC", "VB" and "NM".
>
>
> OK, I solved it - I think. I changed the code to:
>
> while (! [scanner isAtEnd])
> {
> if ([scanner scanUpToCharactersFromSet:stopSet intoString:&result])
> {
> [scanner scanCharactersFromSet:stopSet intoString:&extra];
>
> if (! [scanner isAtEnd] )
> result = [result stringByAppendingString:extra];
>
> [anArray addObject:result];
> }
> }
>
You can substitute "nil" for "&result". I misunderstood what you were
trying to do with your example, so I told you how to read the separators
into the array, rather than the "data". The solution is to simply to do the
opposite of what I said -- "scanUpTo" into your result string and scan the
characters in your set into nil.
As for tutorials, I should have sent you this way the first time around:
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/Programmin
gTopics/Strings/index.html
It covers strings, character sets and scanners.
Jonathan
Jonathan
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Mon Nov 25 04:12:30 2002
on 11/24/02 9:03 PM, Koen van der Drift at <email_removed> wrote:
>> Unfortunately, this doesn't work. Starting with the string
>> "QWERTYASDFGZXCVBNM" I get three single charcters as result: "A" "C" and "B",
>> instead of "QWERTYA", "SDFGZXC", "VB" and "NM".
>
>
> OK, I solved it - I think. I changed the code to:
>
> while (! [scanner isAtEnd])
> {
> if ([scanner scanUpToCharactersFromSet:stopSet intoString:&result])
> {
> [scanner scanCharactersFromSet:stopSet intoString:&extra];
>
> if (! [scanner isAtEnd] )
> result = [result stringByAppendingString:extra];
>
> [anArray addObject:result];
> }
> }
>
You can substitute "nil" for "&result". I misunderstood what you were
trying to do with your example, so I told you how to read the separators
into the array, rather than the "data". The solution is to simply to do the
opposite of what I said -- "scanUpTo" into your result string and scan the
characters in your set into nil.
As for tutorials, I should have sent you this way the first time around:
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/Programmin
gTopics/Strings/index.html
It covers strings, character sets and scanners.
Jonathan
Jonathan
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Koen van der Drift | Nov 22, 15:06 | |
| Jonathan E. Jackel | Nov 22, 17:04 | |
| Koen van der Drift | Nov 22, 17:18 | |
| Koen van der Drift | Nov 23, 18:34 | |
| Koen van der Drift | Nov 24, 01:12 | |
| Jonathan Jackel | Nov 25, 00:04 | |
| Koen van der Drift | Nov 25, 02:37 | |
| Koen van der Drift | Nov 25, 03:03 | |
| Jonathan Jackel | Nov 25, 04:12 | |
| Koen van der Drift | Nov 25, 14:54 | |
| Koen van der Drift | Nov 29, 20:02 | |
| Jonathan Jackel | Nov 30, 04:06 |






Cocoa mail archive

