Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kalisphoenix

macrumors 65816
Original poster
Jul 26, 2005
1,231
1
Let us bow our heads. Have mercy on the n00b. Amen.

I'm working on a new program that looks a lot like iTunes but really manages a whole bunch of text files. Or, actually, a whole bunch of text fields in a big database. Either way, I like smart folders and smart playlists. Is there any way to get that functionality? I haven't seen any palettes for Interface Builder or, God Forbid, an Honest-to-$DEITY tutorial for using them, so I'm assuming the worst.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
kalisphoenix said:
Let us bow our heads. Have mercy on the n00b. Amen.

I'm working on a new program that looks a lot like iTunes but really manages a whole bunch of text files. Or, actually, a whole bunch of text fields in a big database. Either way, I like smart folders and smart playlists. Is there any way to get that functionality? I haven't seen any palettes for Interface Builder or, God Forbid, an Honest-to-$DEITY tutorial for using them, so I'm assuming the worst.
You probably want to use the Spotlight API. If you're using Cocoa, you should have a look at NSMetadataQuery, NSMetadataItem, and NSPredicate (and there are Carbon equivalents). This should allow you do do live searching and smart-folder type things with text files. You can find a good tutorial on how to use it all here, although you'll need to have a fairly good understanding of Cocoa before reading it. It's not really hard to use, but it's not quite for Cocoa newbies either.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
For smart folders you have to roll-your-own solution. There is an example of how to do something similar in the developer examples installed with the tools involving building a search query. You'd then store that query so when the smart folder was opened you'd run the query.

There's a number of ways to do searching. Spotlight's cool but it's Tiger only and only works on individual files not files containing multiple records.(AFAIK). You could also take a look at SearchKit which works in 10.3 but was considerably updated in Tiger and is a bit more flexible.

Oh, and you'll need icons and stuff for the folders in the GUI. You shouldn't just pinch Apple's:rolleyes:
 

kalisphoenix

macrumors 65816
Original poster
Jul 26, 2005
1,231
1
I'm not intending on distributing this, really. Although if I felt it was really good, I might either open-source it or sell it for a pittance, depending on whether or not my alternative is living on the street sucking **** for McDonald's money. That being said, I probably shouldn't show you my mock-up then ;) ;) ;)

Yeah, I'm a Cocoa newbie. More to the point, I'm an Objective-C newbie, a C newbie, and a programming newbie :( But I'll work pretty damned hard on this, I'll guarantee you that much. It's just difficult starting out because I don't have a strict "Method = ________, Instance Variable = _______" sorta sheet. I have an O'Reilly book on Cocoa, but it's pretty dense. I think I'm getting it, though.
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
The best advice I can give to a new cocoa developer is read the bit about memory management really well. If you want to keep your hair I'd recommend using alloc and retain only when you really need to - often using a class method (like [NSArray array....]) is a better idea.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.