在我的objective-c程序中,无论系统的默认浏览器是什么,我都需要在Safari中打开一个URL.这意味着这不起作用,因为它可以启动Firefox或其他任何浏览器:
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
[ws openURL: url];
Run Code Online (Sandbox Code Playgroud)
我想我很接近这个:
[ws launchAppWithBundleIdentifier: @"com.apple.Safari"
options: NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor: NULL
launchIdentifier: nil];
Run Code Online (Sandbox Code Playgroud)
只需要弄清楚如何传递URL作为参数......有更简单的方法吗?
谢谢!
更新:以下代码使用我想要的URL启动Safari,但Safari立即终止!任何想法为什么会这样?
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
[ws openURLs: urls withAppBundleIdentifier:@"com.apple.Safari"
options: NSWorkspaceLaunchDefault
additionalEventParamDescriptor: NULL
launchIdentifiers: NULL];
Run Code Online (Sandbox Code Playgroud)
我观察到了同样的行为LSOpenFromURLSpec.如果Safari实例正在运行,它可以正常工作.如果没有运行Safari实例,它将启动一个新实例并立即终止它.
更新2: Safari仅在嵌入了Flash的网站崩溃.根据上面的代码,我可以很好地打开google.com,例如,Safari会崩溃为YouTube视频.
我知道Doxygen要生成文档.我正在寻找的是在Xcode中插入文档的快速方法,类似于Eclipse在编辑Java文件时所做的操作.
假设我有一个带有几个这样的参数的objective-c方法:
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
Run Code Online (Sandbox Code Playgroud)
在Eclipse中,如果将光标放在方法上方并键入:/**<Enter>您将获得一个预先填充了@param和@return标记的Javadoc模板.
是否有可能在Xcode中实现类似的功能?输入后/**<Enter>,我想自动获取:
/**
*
* @param one
* @param two
*
* @return
*/
-(NSInteger*) sumOf: (NSInteger*) one and:(NSInteger*) two {...
Run Code Online (Sandbox Code Playgroud)