如何静音" UIRemoteNotificationType已被弃用"使用Swift中的iOS sdk 8.3

时间:2015-04-27 10:59:46

标签: ios xcode swift

在我的应用程序中,我需要保持对iOS 7的支持。由于iOS 7中的某些Api可用于iOS 7,我根据用户的系统切换我的代码。

    if operatingSystem() > 7 {
        let types = UIUserNotificationType.Alert | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
        UIApplication.sharedApplication().registerUserNotificationSettings(settings)
        UIApplication.sharedApplication().registerForRemoteNotifications()
    }else {
        UIApplication.sharedApplication().registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound)
    }

显然,iOS 7的代码块包含已弃用的代码,但我需要将其保存在我的应用程序中。是否可以将警告静音?

请注意,这个问题涉及swift而非客观c。我无法使用#pragma添加clang信息。

1 个答案:

答案 0 :(得分:3)

您必须输入-Wno-否定警告。例如:项目的构建阶段选项卡中的编译器标志列中的-Wno-unused-parameter。转到项目然后定位然后选项卡然后编译源阶段。有编译器标志。

应该适合你。