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.
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.






Cocoa mail archive

