0
試圖將其轉換爲Swift 3.0時出現問題。無法調用非函數類型的值
我:
public func calendarView(_ view: DDCalendarView, eventsForDay date: Date) -> [Any]? {
let daysModifier = (date as NSDate).days(from: Date())
//var daysMod = date.days(from: Date())
//var newE = self.events(forDay: daysModifier as Int) as NSArray
var Good = self.events(forDay: daysModifier) as Any
var dates = [NSMutableArray]()
var e:DDCalendarEvent
for e in Good as! [AnyObject] {
if e.dateBegin(isEqual(date)) as! Bool == true || e.dateEnd(isEqual(date)) as! Bool == true {
dates.append(e as! NSMutableArray)
}
}
return dates
}
如果e.dateBegin(的isEqual(日期)){}是給這種錯誤的情況。 而Objective-C代碼的代碼是:
- (NSArray *)calendarView:(DDCalendarView *)view eventsForDay:(NSDate *)date {
//should come from db ;) NOW using testdata
NSInteger daysMod = [date daysFromDate:[NSDate date]];
NSArray *newE = [self eventsForDay:daysMod]; //always today ;)
NSMutableArray *dates = [NSMutableArray array];
for (DDCalendarEvent *e in newE) {
if([e.dateBegin isEqualDay:date] ||
[e.dateEnd isEqualDay:date]) {
[dates addObject:e];
}
}
return dates;
}
和isEqualDay功能
- (BOOL)isEqualDay:(NSDate *)date {
NSDateComponents *compA = self.currentCalendarDateComponents;
NSDateComponents *compB = date.currentCalendarDateComponents;
return ([compA day]==[compB day] && [compA month]==[compB month ]&& [compA year]==[compB year]);
}
其返回bool值的任何解決方案呢?
@rmddy讓我申請你的代碼,你suggest.will儘快回覆您.btw你是主謀。 –
這個函數返回一個數組public func calendarView(_ view:DDCalendarView,eventsForDay date:Date) - > [Any] { 代替日期我需要放任何數據源方法,否則它顯示錯誤.. –
好的,請隨時進行一些更改。我對你的'DDCalendarView'類一無所知。我只是試圖提供更好的翻譯。有可能會需要一些小的改變。 – rmaddy