On Apr 8, 2008, at 6:37 PM, Mike wrote:

If you really are using NSDirectoryEnumerator to scan a large hierarchy for applications, be sure to use an inner auto-release pool to clean up intermediate objects as you go. Also, once you detect that a path corresponds to a bundle (+[NSBundle bundleWithPath:] returns non-nil), use -[NSDirectoryEnumerator skipDescendents] to avoid enumerating the contents of the bundle -- unless you're really interested in applications buried inside of other applications, it will just be wasted time.

Yeah, I found that out the hard way. I just check for bundle or .app and when I hit one, I immediately check its creator code. If it's not the one I want, I skip descendents and it works fine. Before that it would iterate everything and when it hit a huge app like Garageband it would take forever. And I am enumerating from the vol. root.

I should point out that checking whether [NSBundle bundleWithPath:] returns non-nil is probably not what you want. You can create an NSBundle from any readable directory, and it will operate using whatever bundle structures are present within that directory. More likely what you are interested in is whether a particular directory is a file package, i.e., whether it is intended to be presented to the user as a single opaque object; this information can be obtained from NSWorkspace or Launch Services, which can also provide additional information such as whether a particular directory represents an application. Looking for an extension such as .app is not necessarily reliable for this purpose.

Douglas Davidson

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to