Rick,
You could also use:
NSBundle pluginBundle = [NSBundle bundleWithPath: fullPath];
This will return an NSBundle object as your require or nil if fullPath
does not identify an accessible bundle directory. So...
if ( pluginBundle == nil ) ... then it is not a valid bundle.
You will also want to create a protocol that the plugin's Principal
class must conform to. So, a little snippet here for you that will
load a valid bundle that conforms to MyPluginProtocol.
- (id)loadBundleNamed:(NSString*)bundleName {
Class exampleClass;
id newInstance;
NSString *bundlePath = [NSString stringWithFormat:@%@/
%...@.mypluginext,[self pluginDirectory],bundleName];
NSBundle *bundleToLoad = [NSBundle bundleWithPath:bundlePath];
if (exampleClass = [bundleToLoad principalClass]) {
if ( [[bundleToLoad principalClass] conformsToProtocol:@protocol
(MyPluginProtocol)] ) {
newInstance = [[exampleClass alloc] initWithPlugInController:
[PluginController sharedManager] bundle:[NSBundle mainBundle]];
// initWithPluginController is a method defined by
MyPluginProtocol... so I am safe to use it
return [newInstance autorelease];
}
}
return nil;
}
Brad Goss
brad.g...@gmail.com
On 2009-09-24, at 21:41 , Rick Mann wrote:
I'm scanning a directory for plugins for my app. Given a path,
what's the right way to tell if it's a path to a bundle?
TIA
--
Rick
___
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/brad.goss%40gmail.com
This email sent to brad.g...@gmail.com
___
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