Re: "weak link" framework refs for 10.1 compatibility?
Re: "weak link" framework refs for 10.1 compatibility?
- Subject: Re: "weak link" framework refs for 10.1 compatibility?
- From: Ondra Cada <email@hidden>
- Date: Sun, 10 Nov 2002 20:21:31 +0100
On Sunday, November 10, 2002, at 05:30 , Rosyna wrote:
-(void)getRKAliasClass
{
thisBundle=[NSBundle bundleForClass:[self class]];
So far as this is needed only inside the if block below, you should
declare and create it there
if (NSClassFromString(@"RKAlias")==NULL)
For a class there is the "Nil" constant -- "NULL" belongs to pointers.
{
NSBundle* rkBundle=[NSBundle bundleWithPath:[NSString
stringWithFormat:@"%@/%@",[thisBundle
It's not that good to create paths manually this way. See
stringByAppendingPathComponent: and similar methods.
privateFrameworksPath],@"Protocol7Additions.framework"]];
[rkBundle load];
RKAliasClass=NSClassFromString(@"RKAlias");
This line seems to be kinda superfluous, since...
}
RKAliasClass=(NSClassFromString(@"RKAlias"));
...this is performed immediately afterwards. Also, why the parentheses?!?
That all said, the general pattern is quite sound, although I would rather
encapsulate it this way:
...
-(NSBundle*)bundleContainingClassNamed:(NSString*)className {
... this depends on your application; we had a quite complicated
system for searching all available plugins ...
}
-(Class)classWithName:(NSString*)className {
Class class=NSClassFromString(className);
if (!class) {
NSBundle *bundle=[self bundleContainingClassNamed:className];
if (!bundle) [NSException raise:OCSNoBundleForNamedClassException
format:...];
class=NSClassFromString(className);
if (!class) [NSException
raise:OCSClassInBundleListInconsistencyException format:...];
}
return class;
}
...
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.