• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "weak link" framework refs for 10.1 compatibility?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: "weak link" framework refs for 10.1 compatibility?
      • From: Rosyna <email@hidden>
References: 
 >Re: "weak link" framework refs for 10.1 compatibility? (From: Rosyna <email@hidden>)

  • Prev by Date: Re: Path and new folders
  • Next by Date: Re: Move a file to the Trash
  • Previous by thread: Re: "weak link" framework refs for 10.1 compatibility?
  • Next by thread: Re: "weak link" framework refs for 10.1 compatibility?
  • Index(es):
    • Date
    • Thread