我在 javascript 文件中有一个函数,该函数必须将数据(日期、开始时间和结束时间)传递给构建 ios 日历的函数。我能怎么做?
函数javascipt:
function AddItemToCalendarDevice(startdatetime,enddatetime,title){
if (android){
AndroidFunction.AddCalendarItemDateTime(startdatetime,enddatetime,title);
}
else if (ios){
//How can I do?
}
}
ios功能:
- (NSMutableArray *)fetchEvents
{
NSDate *startDate = [NSDate date];
//Create the end date components
NSDateComponents *tomorrowDateComponents = [[NSDateComponents alloc] init];
tomorrowDateComponents.day = 1;
NSDate *endDate = [[NSCalendar currentCalendar]
dateByAddingComponents:tomorrowDateComponents
toDate:startDate
options:0];
// We will only search the default calendar for our events
NSArray *calendarArray = [NSArray arrayWithObject:self.defaultCalendar];
// Create the predicate
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate
endDate:endDate
calendars:calendarArray];
// Fetch all events that match the predicate
NSMutableArray *events = [NSMutableArray arrayWithArray:[self.eventStore eventsMatchingPredicate:predicate]];
NSLog(@"l'array di eventi è %@", events);
return events;
}