在 swift 中从 iOS 应用程序启动 App Store



这段代码有什么问题?

   @IBAction func Button(sender: AnyObject) {
    NSString *iTunesLink = @"https://itunes.apple.com/us/app/apple-store/id375380948?mt=8";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}

我不断收到一些错误,例如"预期声明","预期属性名称"等

看起来你把Objective-C和Swift混为一谈了。

如果您使用的是 Swift,请尝试:

var iTunesLink = "https://itunes.apple.com/us/app/apple-store/id375380948?mt=8"
UIApplication.sharedApplication().openURL(NSURL(string: iTunesLink)!)

最新更新