无法将类型'(Date?,Bool,inout UnsafeMutablePointer <objcbool>?)的值转换为预期的参数类型'(Date?,Bool,inout Bool)

时间:2017-03-31 04:51:14

标签: swift3

  var nextScheduleDate:NSDate?
  calendar.enumerateDates(startingAfter: referenceDate, matching: components, matchingPolicy: .nextTimePreservingSmallerComponents) {

    (scheduleDate: Date?, exactMatch: Bool, stop: inout UnsafeMutablePointer<ObjCBool>?) in

1 个答案:

答案 0 :(得分:0)

不要在(回调)闭包中注释解决问题的类型

calendar.enumerateDates(startingAfter: referenceDate, 
                             matching: components, 
                       matchingPolicy: .nextTimePreservingSmallerComponents) {
                                          (scheduleDate, exactMatch, stop) in
...

找出正确语法的简单方法是注释掉行,重新键入第一个字符并使用代码完成,您将看到实际的闭包签名

  

(约会?,Bool,inout Bool)

这正是错误消息所指的签名。

顺便说一下,在Swift 3中,日期有一个原生结构Date

var nextScheduleDate: Date?