我有使用 ScriptingBridge 使 Safari 打开 URL 的 Objective-C 代码。就像是:
#import "Safari.h" /* created by executing "sdef /Applications/Google\ Chrome.app | sdp -fh --basename GoogleChrome" */
if ((safariApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.Safari"]) == nil) {
NSLog(@"couldn't access Google Chrome");
} else {
NSString *theUrl = [NSString stringWithUTF8String:"http://www.ford.com"];
NSDictionary *theProperties = [NSDictionary dictionaryWithObject:theUrl forKey:@"URL"];
SafariDocument *doc = [[[safariApp classForScriptingClass:@"document"] alloc] initWithProperties:theProperties];
[[safariApp documents] addObject:doc];
}
我想创建类似的代码,为 Chrome 而不是 Safari 做同样的事情。显然,我需要将“Safari.h”更改为“GoogleChrome.h”,将“com.apple.Safari”更改为“com.google.Chrome”。我不确定如何更改最后三行 - GoogleChrome.h 中没有“GoogleDocument”的定义