我已经创建了Safari扩展[通过本地方式创建]
其中,我开始在Safari浏览器中打开新标签
单击按钮:
- (IBAction)btnClick:(id)sender {
[self.sfWindow openTabWithURL:[NSURL URLWithString:@"https://www.facebook.com"] makeActiveIfPossible:true completionHandler:^(SFSafariTab * _Nullable tab) {
NSLog(@"Naman Vaishnav");
}];}
我得到 self.sfWindow :null
答案 0 :(得分:0)
CFURLRef httpURL = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("http://"), NULL);
NSLog(@"%@", LSCopyDefaultApplicationURLForURL(httpURL, kLSRolesAll, nil));
NSString *strDefaultBrowser = [NSString stringWithFormat:@"%@",LSCopyDefaultApplicationURLForURL(httpURL, kLSRolesAll, nil)];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:websiteName]];