IPhone: How long does it take to search?
Search? In what sense?
If you just use:
[myStringArray containsObject:searchString];
then 200-300 lines can be searched within a few microseconds.
If you are looking for:
BOOL found = NO
for (NSString *string in myStringArray)
{
if ([string rangeOfString:searchString].location != NSNotFound)
{
found = YES;
break;
}
}
Then it almost entirely depends on the length of each line, but for lines less than a few dozen characters, it is about the same as the previous search speed.
Remote search is completely different - but it is a huge waste of time for such an operation. It is completely based on network latency. With an average ping of 250ms, the average time for a remote operation is about half a second or more, because it takes a long time to generate network packets, send over the network, wait for the remote server to receive, wait for the remote server to process, wait for a response, and parse the response.
If this question was round, ask: do I just need to iterate over all 30 lines and search locally - then: yes, search locally. Generally: Local searches are faster until the time taken to download all of the results becomes a burden (compared to 3G, I usually consider 50KB as the maximum for fast transparent downloads).
a source to share
This applies to local string searches.
I have implemented a Trie data structure to index rows for fast autocomplete. http://en.wikipedia.org/wiki/Trie
a source to share