NSCalendar *cal = [NSCalendar currentCalendar];NSDate *Now = [NSDate date];NSDate *startOfTheWeek;NSTimeInterval interval;[cal rangeOfUnit:NSWeekCalendarUnit startDate:&startOfTheWeek interval:&interval forDate:Now];
它会写本周开始的时候开始的周期和周期间隔.
在我写的 *** 场上
let Now:NSDate = NSDate()var startDate:NSDatevar duration: NSTimeInterval // also trIEd "var duration: CMutablePointer<NSTimeInterval>"let cal = NSCalendar.currentCalendar()cal.rangeOfUnit(unit: NSCalendarUnit.WeekCalendarUnit,startDate: startDate,interval: duration,forDate: Now)"
虽然代码完成告诉我签名是
cal.rangeOfUnit(<#unit: NSCalendarUnit#>,startDate: autoreleasingUnsafePointer<NSDate?>,interval: <#CMutablePointer<NSTimeInterval>#>,forDate: <#NSDate?#>)
我究竟做错了什么?
我也试过了
cal.rangeOfUnit(NSCalendarUnit.WeekCalendarUnit,forDate: Now)
但这会产生错误
试试这个:“Could not find an overload for ‘rangeOfUnit’ that accepts the supplIEd arguments.”
let Now = NSDate()var startDate: NSDate? = nilvar duration: NSTimeInterval = 0let cal = NSCalendar.currentCalendar()cal.rangeOfUnit(NSCalendarUnit.WeekCalendarUnit,startDate: &startDate,interval: &duration,forDate: Now)
(默认情况下,第一个参数没有外部名称,因此不应该命名.)
总结以上是内存溢出为你收集整理的swift – 将参数传递给方法时出现“调用中的额外参数”错误全部内容,希望文章能够帮你解决swift – 将参数传递给方法时出现“调用中的额外参数”错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)