尝试创建本地通知但在swift 2中收到错误"无法调用非函数类型uilocalnotification的值"

1 xcode ios uilocalnotification swift swift2

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()


        var dateComp:NSDateComponents = NSDateComponents()
        dateComp.year = 2015;
        dateComp.month = 11;
        dateComp.day = 20;
        dateComp.hour = 0;
        dateComp.minute = 10;
        dateComp.timeZone = NSTimeZone.systemTimeZone()

        var calendar:NSCalendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)!
        var date:NSDate = calendar.dateFromComponents(dateComp)!
        //var date:NSDate = calendar.dateFromComponents(dateComp)

        var notification:UILocalNotification = UILocalNotification()
        notification.category = "FIRST_CATEGORY"
        notification.alertBody = "HI, noti "
        notification.fireDate  = date

        UIApplication.sharedApplication().scheduledLocalNotifications(notification)


        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
//trying to create a local notification but getting error " cannot call value of non function type uilocalnotification " in swift 2 
Run Code Online (Sandbox Code Playgroud)

JAL*_*JAL 8

你需要打电话scheduleLocalNotification,而不是scheduledLocalNotifications(注意时间表不安排d):

UIApplication.sharedApplication().scheduleLocalNotification(notification)
Run Code Online (Sandbox Code Playgroud)