On Sep 11, 2009, at 4:47 AM, Farooq zaman wrote:

I want to develop a text searching system for my application. This system should search for a search expressions in all files present is a particular project directory. Can anybody tell me what COCOA classes used for text searching?

There isn't anything in Cocoa that will search through files. You could read a file into memory using +[NSString stringWithContentsOfFile:usedEncoding:error] and then use -[NSString rangeOfString:] to look for string you want to match, but this will be really inefficient, especially with large files or large numbers of files.

If you need to search for general patterns, not just literals, look into RegexKitLite.

Optimally you'd want to open each file as a stream and read through it for the pattern. (You might want to read up on efficient string-search algorithms like Boyer-Moore or Rabin-Karp.) You can do this using standard C or POSIX file APIs.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to