Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 8, 2013, 04:26 PM   #1
larswik
macrumors 65816
 
Join Date: Sep 2006
Searching Directory for items

I have a little Mac program that I wrote a while back to help me manage a small data base of graphics and info for a local grocery store. The data base has grown so large that it is hard for me to find things and the items that get sent to me become hard to look up just scanning through the directory. 1 entry might be "Wine Firestone" and another might be "Sunstone Wine". IF I look under "W" for wine I would miss sunstone.

So I thought I would add a search bar to my program which I have never done before. My goal is to enter a search word like wine and every entry that has the word "wine" in it would be displayed.

I was going to use NSFileManager to get a list of the items in a directory and in to an array. Then I was going to check each index to see if there is a sub string that matches the string that I am looking for. If there is a match add it to a new mutableArray. After the search display in a tableview.

Is that about the correct process to do this?
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Jan 8, 2013, 04:45 PM   #2
KoolStar
macrumors Demi-God
 
KoolStar's Avatar
 
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
I believe that would be the most common approach. I would use the nsrange and use its range function for a string if it exist then they text contains the string you are checking for.
__________________
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote
Old Jan 8, 2013, 08:53 PM   #3
ytk
macrumors regular
 
Join Date: Jul 2010
Just make sure your comparison isn't case-sensitive. One way to do this is to convert both your search and filename strings to upper or lower case before comparison, using NSString's upperCase or lowerCase methods.
ytk is offline   0 Reply With Quote
Old Jan 8, 2013, 10:39 PM   #4
subsonix
macrumors 68040
 
Join Date: Feb 2008
Just to see if I understand, your items are files in a folder? Your program looks for a string match (the search term) to a file name?
subsonix is offline   0 Reply With Quote
Old Jan 8, 2013, 10:53 PM   #5
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
subsonix - Yes. I need a way to filter the data which will be string.
ytk - I forgot about that, good point.
KoolStar- Ok, so this is the approach. Objective C is so vast that I was not sure if some special class existed to do this. I was wondering if some one was going to mention a class that I was unaware of that helped it out. But it seems that this approach is the right way.

Thanks!
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Jan 8, 2013, 11:46 PM   #6
Sayer
macrumors 6502a
 
Sayer's Avatar
 
Join Date: Jan 2002
Location: Austin, TX
Take a look at Search Kit https://developer.apple.com/library/...reference.html
__________________
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
copy a directory using bash - how to do it? error: is a directory (not copied). cupboy1 OS X 10.8 Mountain Lion 0 Mar 23, 2014 09:50 PM
Searching email LastZion iOS 7 3 Jun 25, 2013 09:15 AM
iPad Mini: Still Searching To Buy One? AppleRobert iPad 29 Nov 20, 2012 01:32 PM
Not all items being tagged when tagging multiple items in iTunes willryan42 Mac Applications and Mac App Store 0 Oct 8, 2012 06:44 PM
Searching for Macbook racer1441 MacBook 4 Aug 22, 2012 08:54 AM

Forum Jump

All times are GMT -5. The time now is 05:38 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC