I had a problem turning a String into a date, and I was able to put it in the exact time, but now when I went to generate the notification, the blessed date appears with a few more hours, I did everything I thought it could be but not I get the solution
{...
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd MMM yyyy HH:mm"
dateFormatter.locale = NSLocale.currentLocale()
dateFormatter.timeZone = NSTimeZone.localTimeZone()
let date2 = dateFormatter.dateFromString(dateStr4)
dateFormatter.dateFormat = "dd/MM/yyyy HH:mm"
if let unwrappedDate = date2 {
print(dateFormatter.stringFromDate(unwrappedDate)) //26/09/2016 21:23
criaNotificacoes(unwrappedDate, comIntervalo: util.valorIntervalo(campoIntervalo.text!), totalDias: util.valorTempoDias(campoPeriodo.text!))
}else{
print("tratar")
}
}
func criaNotificacoes(dataInicio: NSDate, comIntervalo intervalo:Int, totalDias qtdDias:Int){
print("data de inicio recebida --->",dataInicio)//2016-09-27 00:23:00
let dateComponentes = NSDateComponents()
let calendario = NSCalendar.currentCalendar()
calendario.timeZone = NSTimeZone.localTimeZone()
calendario.locale = NSLocale.currentLocale()
dateComponentes.timeZone = NSTimeZone.localTimeZone()
var fireDate: NSDate = NSDate()
fireDate.descriptionWithLocale(NSLocale.currentLocale())
fireDate = calendario.dateByAddingComponents(dateComponentes, toDate: dataInicio, options: NSCalendarOptions())!
print(fireDate,"data inicio")//2016-09-27 00:23:00
}