【问题标题】:How to link an application classes to F-Script如何将应用程序类链接到 F-Script
【发布时间】:2010-06-28 23:43:56
【问题描述】:

我想创建一个命令行应用程序,它接受执行的脚本 F-Script,并且可以访问应用程序公开的某些类。

我该怎么做?

PS:我指的是F-Script,而不是FScript

【问题讨论】:

    标签: objective-c osx-snow-leopard f-script


    【解决方案1】:

    查看FScript.app的代码,据说链接了大部分Core框架,发现如下方法:

    - (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];
    }
    

    我认为链接到从应用程序定义的类足以加载包含这些类的包。

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      • 2011-03-15
      相关资源
      最近更新 更多