Re: Is this an incorrect use of categories ?
Re: Is this an incorrect use of categories ?
- Subject: Re: Is this an incorrect use of categories ?
- From: Erik Stainsby <email@hidden>
- Date: Thu, 05 Jul 2012 20:54:00 -0700
Thanks for the reply Graham.
The categories are loaded in a window controller which serves as the context for the plugins. The plugins are loaded with a convenience method from my framework, which uses NSBundle loading techniques.
Is it sufficient that the categories be loaded in the windowController code? Or do they need to be available in the framework context in which the plugins are actually loaded from nib? That is, my categories are being added in the app not in the framework.
RSRuleWindowController.m:
#import "RSRuleWindowController.h"
#import "NSView+RSPositionView.h"
#import "DOMElement+RSLDOMExtensions.h"
#import "RSActionRule+RSActionRuleFromPlugin.h"
#import "RSFilterRule+RSFilterRuleFromPlugin.h"
#import "RSReactionRule+RSReactionRuleFromPlugin.h"
#import "RSActionPlugin+RSActionPluginFromRule.h"
#import "RSFilterPlugin+RSFilterPluginFromRule.h"
#import "RSReactionPlugin+RSReactionPluginFromRule.h"
@implementation RSRuleWindowController
- (id) init {
self = [super initWithWindowNibName:@"RSRuleWindow"];
if (self) {
_rules = [NSMutableDictionary dictionary];
RSTrixieLoader *loader = [[RSTrixieLoader alloc] init];
self.actionPlugins = [loader loadPluginsWithPrefix:@"Action" ofType:@"bundle"];
self.filterPlugins = [loader loadPluginsWithPrefix:@"Filter" ofType:@"bundle"];
self.reactionPlugins = [loader loadPluginsWithPrefix:@"Reaction" ofType:@"bundle"];
loader = nil;
}
return self;
}
[…]
@end
On 2012-07-05, at 8:23 PM, Graham Cox <email@hidden> wrote:
>
> On 06/07/2012, at 12:50 PM, Erik Stainsby wrote:
>
>> However, I am getting an "unrecognized selector sent to instance 0xyaddayadda" when I try to run this. I know the selector does exist, so I must have a scoping issue (?)
>
>
> At run-time, if the target object implements the selector (whether in a category or otherwise), you won't get this message. So, the target object is either not what you think it is, or the category wasn't attached.
>
> If the selector is supplied by a category, then the category must have been loaded in order to be attached to the class. If that category is implemented by the plug-in, you must have loaded and linked the plug-in before calling the method, so if that's the case I'd be looking at where and how you are doing this - usually you use the methods of the NSBundle class to load your plug-in. e.g. -loadAndReturnError:
>
> It's not that clear from what you posted where the category is defined and implemented - in your app or in the plug-in.
>
>
> --Graham
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden