简体   繁体   English

使用url方案传递参数

[英]Passing parameters using url scheme

I am working on a app which could be launched over a URL. 我正在开发一个可以通过URL启动的应用程序。 I have already defined my url scheme using xcode on info page. 我已经在信息页面上使用xcode定义了我的网址方案。 I filled for identifier my Bundle identifier and for URL Schemes myapp. 我填写了标识符我的Bundle标识符和URL Schemes myapp。

Now if I try to open in safari myapp://foo, it launches my app and stops at my breakpoint in 现在,如果我尝试在safari myapp:// foo中打开,它会启动我的应用程序并在我的断点处停止

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation

method. 方法。

Problem is annotation, url, application, sourceapplication parameters are nil. 问题是注释,url,应用程序,sourceapplication参数都是nil。 So I can not pass parameters... 所以我不能传递参数......

在此输入图像描述

After unnecessary time loss, I have found out, the problem was the debugger. 在不必要的时间丢失之后,我发现问题是调试器。 It shows the url is nil and if I try to print description it says 它显示网址是零,如果我尝试打印说明它说

Printing description of url:
<nil>

But If I try to NSLog it shows the url. 但如果我尝试NSLog,它会显示网址。 And if put the following code in the method 如果在方法中放入以下代码

if (! url) {
    return NO;
}

The debugger shows also the url. 调试器还显示url。

Are you sure your project is in debug mode!? 你确定你的项目处于调试模式!? See here http://nerdwa.com/index.php/2011/09/debugrelease-schemes-in-xcode-4/ 请参见http://nerdwa.com/index.php/2011/09/debugrelease-schemes-in-xcode-4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM