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

Launching the App Store from an iOS application in swift

这段代码有什么问题?

   @IBAction func Button(sender: AnyObject) {

    NSString *iTunesLink = @"https://itunes.apple.com/us/app/apple-store/id375380948?mt=8";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}

我不断收到一些错误,例如 "Expected Declaration"、"Expected an attribute name" 等

您似乎混淆了 Objective-C 和 Swift。

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

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