gpt4 book ai didi

ios - 没有更多上下文swift4,表达式类型不明确

转载 作者:行者123 更新时间:2023-11-28 05:59:19 25 4
gpt4 key购买 nike

我得到的错误是:

"Type of expression is ambiguous without more context swift4"

我正在为 iPhone 应用程序制作本地通知提醒页面。我正在使用 Xcode 9 和 Swift 4。

import UIKit
@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate
{
var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
// Override point for customization after application launch.

if(UIApplication.instancesRespond(to: Selector("registerUserNotificationSettings:"))) {
UIApplication.sharedApplication.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert | .Badge, categories: nil))
}

return true
}

func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
application.applicationIconBadgeNumber = 0
}

最佳答案

您遇到的问题是因为代码的语法不正确。您在此处发布的代码位于 Swift-2 中,这就是它给您语法错误的原因。

Swift-4 中使用以下代码:

UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings.init(types: [.alert, .badge], categories: nil))

如果您仍然遇到任何问题,请告诉我。

关于ios - 没有更多上下文swift4,表达式类型不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50303525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com