Calculate age from birth date

前端 未结 4 727
北荒
北荒 2020-12-09 06:34

I cant find age in from birth date. What I got is

fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb) 

My code

4条回答
  •  不思量自难忘°
    2020-12-09 07:20

    Just use the DateTools pod. Absolutely the easiest way. https://github.com/MatthewYork/DateTools

    For Swift 3

    import DateTools
    
    let birthday: Date = ....
    let ageString = String((Date() as NSDate).years(from: birthday))
    

提交回复
热议问题