Hi All,

I have a general design question. I'm going through the latest Hillegass and
Kochan programming books for the purpose of writing a simple search app. I
think I've figured out a way to do this, but having no experience in
programming, I have no idea if my approach is good or bad. I'd rather not
take the stupid road if I can avoid it, so I'm hoping someone may be able to
set me straight before I go too far down the road.

So if you're inclined to take a few minutes to consider what I've written
below, I'd appreciate it.

In any case, good luck with your projects,

 David

--------------------------------------------------------------------------------------------

*APPLICATION DESCRIPTION:*
I have a library of about 1,500 text files, about 93 MB total.

The application window opens with two views: left view shows the hierarchy
of folders/files, and when you click on a file, the text of the file appears
in the right view, where you can read, scroll, etc.

The user inputs a term into the search field, and when the search is
executed, the folders/files on the left view disappear and the view is
repopulated with a new hierarchy showing only the folders/files where the
search term appears. Below each file will be snippets of where the term
appears within the text. Click on a snippet and the right view will show the
entire text of the file zoomed to where the snippet appears.

For example, if the search term is "child education":

*Book X*
   The *child education* conference focused on two age groups: 5-7 years,
and 8-10 years.
     .  .  . because the *child* wasn't receiving the needed attention in
her *education*, her parents decided  .  .  .
     .  .  .  and over the years the *child education* policy was broadened
to include moral education and  .  .  .


*MY APPROACH*:
I can load the text of the 1,500 files into 1500 NSStrings with something
like

stringWithContentsOfFile


 Then I can search the 1,500 NSStrings to locate the position of the search
term within each string, then extract a range (including some words before
and some words after) to make the snippets. Using


 rangeOfString

NSMakeRange

etc.



*QUESTION:*

Would this be a workable approach? Or is it a really stupid idea to have to
load 93 MB of files into 1,500 NSStrings every time the program starts up?
If not this approach, what would be more efficient?


Thanks.
_______________________________________________

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