質問

実行され、アプリケーションによって公開されたいくつかのクラスにアクセスできるスクリプトf-scriptを受け入れるコマンドラインアプリケーションを作成したいと思います。

どうやってやるの?

: :私は言及しています f-script, 、 いいえ fscript.

役に立ちましたか?

解決

fscript.appのコードを見ると、これはほとんどのコアフレームワークのほとんどにリンクされていると報告されています。次の方法が見つかりました。

- (void)loadSystemFrameworks  // Contributed by Cedric Luthi
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  NSMutableArray *systemFrameworksPaths = [NSMutableArray arrayWithObject:@"/System/Library/Frameworks"];

  if ([[NSUserDefaults standardUserDefaults] boolForKey:@"FScriptLoadPrivateSystemFrameworks"])
    [systemFrameworksPaths addObject:@"/System/Library/PrivateFrameworks"];

  for (NSString *systemFrameworksPath in systemFrameworksPaths)
  {
    for (NSString *framework in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:systemFrameworksPath error:NULL])
    {
      NSBundle *frameworkBundle = [NSBundle bundleWithPath:[systemFrameworksPath stringByAppendingPathComponent:framework]];
      if ([frameworkBundle preflightAndReturnError:nil])
        [frameworkBundle load];
    }
  }

  [pool drain];
}

アプリケーションから定義されたクラスにリンクするために、クラスを含むバンドルをロードするのに十分です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top