我想检查myButton是否有一个命名图像.
我试试这个,但它不起作用
if (myButton.currentImage?.isEqual(UIImage(named: "ButtonAppuyer.png")) != nil){
print("YES")
} else {
print("NO")
}
Run Code Online (Sandbox Code Playgroud)
这也行不通
if myButton.currentImage?.isEqual(UIImage(named: "ButtonAppuyer.png")){
print("YES")
} else {
print("NO")
}
Run Code Online (Sandbox Code Playgroud) 我需要你的一个项目的帮助。
我有 3 个变量,一个用于日,另一个用于月,最后用于年。像那样 :
var year = 2017
var month = 06
var day = 19
即使应用程序在我们处于这些变量的日期时关闭,我也想发送通知,但我对日历和日期不太擅长。我只是暂时制作了这个应用程序。
let myNotification = Notification.Name(rawValue:"MyNotification")
override func viewDidLoad() {
super.viewDidLoad()
let nc = NotificationCenter.default
nc.addObserver(forName:myNotification, object:nil, queue:nil, using:catchNotification)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let nc = NotificationCenter.default
nc.post(name:myNotification,
object: nil,
userInfo:["message":"Hello there!", "date":Date()])
}
func catchNotification(notification:Notification) -> Void {
print("Catch notification")
guard let userInfo = notification.userInfo,
let message = userInfo["message"] as? String,
let date = userInfo["date"] as? Date else { …Run Code Online (Sandbox Code Playgroud)