Xcode - 多个URL方案 [英] Xcode - multiple URL Schemes

查看:262
本文介绍了Xcode - 多个URL方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我想要两个不同的网址方案。

喜欢一个两个

所以用户可以打开我的应用程序:

one:// something



two:// something

In my app I want to have two Different URL Schemes.
Like One and Two
So the user can open my app with:
one://something
and
two://something

我使用的是:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
}

如果用户键入一个或两个,应用程序将如何知道?

How will the app know if the user types one or two?

推荐答案

handleOpenURL 已弃用,因此如果您的目标是iOS 4.2或更高版本,则应改为使用 application:openURL: sourceApplication:annotation:

handleOpenURL is deprecated, so if you're targeting iOS 4.2 or later, you should instead use application:openURL:sourceApplication:annotation:

在这两种情况下,你都将成为p as a NSURL ,您只需访问 计划属性用什么方案来访问你的应用程序。

In both cases, you will be passed an NSURL, on which you can just access the scheme property to find out what scheme was used to access your app.

编辑:为了便于阅读;在你的应用程序的实现中:openURL:sourceApplication:annotation:,代码类似于;

For readability; in your implementation of application:openURL:sourceApplication:annotation:, the code would be something similar to;

if([[url scheme] caseInsensitiveCompare:@"one"] == NSOrderedSame) 
{ 
    /* one here */ 
} else { 
    /* not one here */ 
}

这篇关于Xcode - 多个URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆