小编iro*_*ron的帖子

我如何在swift中获得String当前月份:

我需要得到可能作为当月,但我做不到.我怎样才能做到这一点.

   let date = NSDate()
    let calendar = NSCalendar.currentCalendar()
    let components = calendar.components([.Day , .Month , .Year], fromDate: date)

    let year =  components.year
    let month = components.month
    let day = components.day
Run Code Online (Sandbox Code Playgroud)

我做了这个,但没有奏效.

nsdate nscalendar ios swift

27
推荐指数
3
解决办法
4万
查看次数

标签 统计

ios ×1

nscalendar ×1

nsdate ×1

swift ×1