Re: componentsSeparatedByString:
Re: componentsSeparatedByString:
- Subject: Re: componentsSeparatedByString:
- From: Ambroise Confetti <email@hidden>
- Date: Thu, 30 Oct 2003 00:47:06 +0100
Le 29 oct. 03, ` 23:02, Jonathan E. Jackel a icrit :
>
You are removing anotherString from tmpArray. Could that be your
>
problem?
No, in fact, in my actual code, anotherString is the empty string (@"")
which is found in the array when the users enters successive
whitespaces (aString is a space, @" "). The whole code would work
exactly the same without this line, search included (an empty string
matches anything, but removing it early speeds up the search engine).
>
componentsSeparatedByString only recognizes one delimiter at a time.
>
Unless
>
you are doing something else (recombining quoted search terms, maybe),
>
each
>
word will be a separate object in the array, regardless of any quote
>
marks.
I know that. My actual code is more complex. I use
componentsSeparatedByString: a first time with @"\"", which gives me an
array where items with even indexes are separated words which have to
be split again at whitespaces -- this is what the code I posted does --
and items with odd indexes are literals which must be kept like that...
I know this is a strange way of doing things, but it works (well, when
I use my workaround). If NSString or NSScanner had regexp support, I
would use that.
(I assume that a request like <<one two "three four>> without closing
double quotes implies that the user wanted to type <<one two "three
four">>... But this is another problem anyway.)
>
This doesn't seem like a job for a formatter. It feels more like a
>
delegate
>
or a controller should peek at the textfield and do the search.
The formatter only transforms the array of literals to find into a
string and vice versa. Another objects performs the actual search. This
is a perfect job for a formatter. In this case, the delegate peeks an
already semantically significant object value (the array) instead of a
string value. That's all.
(For instance, if <<one two "three four">> is entered, the formatter
outputs an array containing (@"one",@"two",@"three four"). That's all
the formatter does: make a bidirectional transformation between a
string and its object value.)
Ambroise
http://www.cellulo.info/
ICQ 4508259
AIM atvaark
[demime 0.98b removed an attachment of type text/directory which had a name of Ambroise Confetti.vcf]
_______________________________________________
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.