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 22:29:18 +0100
On Sunday, November 10, 2002, at 08:47 , Rosyna wrote:
That all said, the general pattern is quite sound, although I would
rather encapsulate it this way:
<snip>
But what if the class hasn't been loaded?
Ah, sorry; mea maxima culpa -- my original code which I've copied from for
diverse reasons loaded the bundle inside the helper method
(bundleContainingClassNamed:), and I've forgot to stress it out, or (in
this partcular case more properly) to move the loading into the
classWithName: one.
So, the code should look like this
// fixed version
...
-(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=[bundle classNamed:className]; // here's the important
difference to the original code
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.