Using NSSortDescriptor to sort Dates and nil values

Today I’ve been working on sorting tasks, as I’m using swiftUI and CoreData I use a FetchRequest with the following SortDescriptor: NSSortDescriptor(keyPath: \Task.targetDate, ascending: true) The idea being it will sort based on the task due date from smallest to the largest, meaning you’ll see the ones you should act on first at the top. …

Identifying combinations of dates in text using regex

For the upcoming app I’m working on I need a way to easily detect dates the user may have typed at the end of a line. It was time to re-visit old faithful regex.  After lots of readings and tests I ended up settling on this beauty:       “.*[0-9]{2}/[0-9]{2}” Here’s what it does: The …

Time until next day starts in UTC (Swift)

Although users interact with NewsWave on their iOS and -soon- Mac, some features are provided by a server. So, how can I let users know when the server triggers certain tasks? If they are triggered at regular intervals you can simply calculate on the device how long until it will be triggered again. This reduces calls …

Get Date Day, Month or Year in Swift 3.0

Just a quick update to show how to get Date Day, Month or Year in Swift 3 //Here I’m creating the calendar instance that we will operate with: let calendar = NSCalendar.init(calendarIdentifier: NSCalendar.Identifier.gregorian)         //Now asking the calendar what month are we in today’s date: let currentMonthInt = (calendar?.component(NSCalendar.Unit.month, from: Date()))!           //Now …