本文介绍了尝试创建本地通知,但出现错误“无法调用非函数类型uilocalnotification的值迅速2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
推荐答案
您需要致电scheduleLocalNotification
,而不是scheduledLocalNotifications
(请注意计划不是schedule d ):
You need to call scheduleLocalNotification
, not scheduledLocalNotifications
(note schedule not scheduled):
UIApplication.sharedApplication().scheduleLocalNotification(notification)
这篇关于尝试创建本地通知,但出现错误“无法调用非函数类型uilocalnotification的值迅速2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!