|
|
#1 |
|
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 |
|
|
|
0
|
|
|
#2 |
|
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.
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800 iPhone 4S 16GB | iPhone 5 32GB
|
|
|
|
0
|
|
|
#3 |
|
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.
|
|
|
|
0
|
|
|
#4 |
|
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?
|
|
|
|
0
|
|
|
#5 |
|
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 |
|
|
|
0
|
|
|
#6 |
|
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 |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 03:38 AM.







Linear Mode
