Receiving UILocalNotification after adding it in Swift

I've searched before asking the question but found nothing. I'm using this code to schedule a notification in my app:

    let firstFormatter = NSDateFormatter()
    firstFormatter.dateFormat = "MMMM, dd, HH:mm"

    let date = "\(dueDateTxtField.text) \(notificationTimeTxtField.text)" 

    let fireDate = firstFormatter.dateFromString(date)

    let realNotification = UILocalNotification()
    realNotification.fireDate = fireDate
    realNotification.soundName = UILocalNotificationDefaultSoundName
    realNotification.alertTitle = "Homework reminder"
    realNotification.alertBody = "You have a pending \(subjectTxtField.text) homework for tomorrow."


    let secondFormatter = NSDateFormatter()
    secondFormatter.dateFormat = "yyyy"

    let falseNotification = UILocalNotification()
    falseNotification.fireDate = secondFormatter.dateFromString("2020")
    falseNotification.soundName = UILocalNotificationDefaultSoundName
    falseNotification.alertTitle = "This notification will never get to you"
    falseNotification.alertBody = "Never"

    if notifyMeSegmentedControl.selectedSegmentIndex == 0 {
        UIApplication.sharedApplication().scheduleLocalNotification(realNotification)
    } else {
        UIApplication.sharedApplication().scheduleLocalNotification(falseNotification)
    }

I'm using an UISegmentedControl so the user can choose to receive or not the notification. The thing is that, as soon as I add a new homework (the app is a homework app, where you add a subject, description, etc), I already get the notification, even if I set the "notificationTimeTxtField" to a time that's not now.

Please tell me what I'm doing wrong. Thanks in advance!

EDIT: I'VE TRIED TO PRINT THE FIRE DATE AND IT'S PRITING NIL!! I have no idea why, there is text in the text fields!

Answers


I fixed it. The problem was that the dueDateTxtField was formatted like this: "MMMM, dd, yyyy", and I was trying to format it like "MMMM, dd" only. So I fixed it by formatting both with the same format and it works perfectly.


Need Your Help

What's the output object file format of GNU assembler as?

c linux assembly gnu gas

I have checked the assembler options of GNU assembler as and I didn't find an option to specify the output object file format. If I am using the following command

Android ImageView: Fit Width

android android-layout android-imageview

I download image and set it as a screen background dynamically using Imageview. I have tried ScaleType, to scale the image.