iOS swift-利用口令和粘贴板实现商店跳转,查找店铺

if (HuoDongURL.range(of: "tmall") != nil) {

//不替换掉前缀https为tmall的话,打不开天猫

let tmallUrl = HuoDongURL.replacingOccurrences(of: "https", with: "tmall")

print("复制板内容前:\(UIPasteboard.general.string)")

//给系统剪切板设置内容

UIPasteboard.general.string = "分享生成的口令"

//应用内可用的剪切板

//UIPasteboard.withUniqueName().string = ""

print("复制板内容后:\(UIPasteboard.general.string)")

//判断能否打开天猫

if UIApplication.shared.canOpenURL(tmallUrl!) {

print("打开天猫")

UIApplication.shared.openURL(tmallUrl!)

}

你可能感兴趣的:(iOS swift-利用口令和粘贴板实现商店跳转,查找店铺)