swift3 - Detect a written date/event in a text in Swift 3 -
i'm making chat app , behave apple mail app; means recognizes written dates , underlines them. example: if write email contains: "would meet on friday @ 4pm?" should automatically recognize , underline "friday @ 4pm" , when tap on asks me make reminder event.
unfortunately, haven't found on googling can't provide sample code; still hope has experience that.
here code refer here:-
let input = "this date 2017-02-02" let detector = try? nsdatadetector(types: nstextcheckingresult.checkingtype.date.rawvalue) guard let matches = detector?.matches(in: input, options: [], range: nsrange(location: 0, length: input.utf16.count)) else {return} match in matches { let date = (input nsstring).substring(with: match.range) print(date) }
Comments
Post a Comment