Skip navigation.
 
mlRe: "weak link" framework refs for 10.1 compatibility?
FROM : Ondra Cada
DATE : Sun Nov 10 20:21:31 2002

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_removed>              http://www.ocs.cz
private        <email_removed>            http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
ml"weak link" framework refs for 10.1 compatibility? Dan Wood Nov 7, 20:20
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 8, 11:17
mlRe: "weak link" framework refs for 10.1 compatibility? Dan Wood Nov 9, 16:02
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 9, 16:31
mlRe: "weak link" framework refs for 10.1 compatibility? Marco Scheurer Nov 9, 16:40
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 9, 19:35
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 9, 19:38
mlRe: "weak link" framework refs for 10.1 compatibility? Jonathan Hendry Nov 9, 20:55
mlRe: "weak link" framework refs for 10.1 compatibility? Nicholas Riley Nov 10, 03:17
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 10, 05:30
mlRe: "weak link" framework refs for 10.1 compatibility? Sam Griffith Nov 10, 06:56
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 10, 08:39
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 10, 11:10
mlRe: "weak link" framework refs for 10.1 compatibility? Finlay Dobbie Nov 10, 13:38
mlRe: "weak link" framework refs for 10.1 compatibility? Finlay Dobbie Nov 10, 16:30
mlRe: "weak link" framework refs for 10.1 compatibility? Piers Uso Walter Nov 10, 18:34
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 10, 20:21
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 10, 20:27
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 10, 20:47
mlRe: "weak link" framework refs for 10.1 compatibility? Sam Griffith Nov 10, 21:56
mlRe: "weak link" framework refs for 10.1 compatibility? Finlay Dobbie Nov 10, 22:12
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 10, 22:29
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 10, 23:45
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 11, 01:11
mlRe: "weak link" framework refs for 10.1 compatibility? Marco Scheurer Nov 11, 11:07
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 11, 12:23
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 11, 14:52
mlRe: "weak link" framework refs for 10.1 compatibility? Marco Scheurer Nov 11, 17:27
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 11, 18:11
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 11, 20:51
mlRe: "weak link" framework refs for 10.1 compatibility? Ondra Cada Nov 11, 22:14
mlRe: "weak link" framework refs for 10.1 compatibility? Bill Cheeseman Nov 12, 00:37
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 12, 01:40
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 12, 01:43
mlRe: "weak link" framework refs for 10.1 compatibility? Rosyna Nov 12, 01:45