简体   繁体   English

如何在Kal Calender中进行更改以显示来自JSON Web服务的事件

[英]How to makes changes in kal calender to display events from json webservice

嗨,我正在创建一个iPhone应用程序,其中我使用日历来显示事件。为此,我在项目中使用了Kal Kalender API https://github.com/klazuka/Kal ,我需要根据开始日期和结束时间显示事件日期来自json webservice,所以我必须在kal calender项目中进行更改,以便我可以调用我的开始日期和结束日期并显示该日期的事件。请提供代码给我。谢谢

The Holiday Example in the Kal git is a good place to start. Kal git中的Holiday示例是一个很好的起点。 it also fetchs the events from JSON and shows it in the KalViewController tableView. 它还从JSON获取事件,并将其显示在KalViewController tableView中。

EDIT: I can tell you what i did, i had to show the native calender as well as the JSON events in the Kal calenderView 编辑:我可以告诉你我做了什么,我必须在Kal calenderView中显示本机日历和JSON事件。

so i did not change any implementation of Kal for fetching the native events but i did add my own fetching method for server events and combined the two arrays. 因此,我没有更改用于获取本地事件的Kal的任何实现,但是我确实为服务器事件添加了自己的获取方法,并将两个数组组合在一起。

here's how i did it, i used the nativeCal example and used the same eventkitDatasource.m as my kal datasource 这是我的操作方式,我使用了nativeCal示例,并使用了与我的Kal数据源相同的eventkitDatasource.m

then, in the KalViewDelegate protocol methood 然后,在KalViewDelegate协议中

- (void)didSelectDate:(KalDate *)date 

I sent request to fetch the events from the server for the selected date, on receiving the events array from server, i then add those objects, to an array in the eventkitDatasource.m, and use that array in the 在收到来自服务器的事件数组后,我发送了请求以从选定日期的服务器获取事件,然后将这些对象添加到eventkitDatasource.m中的数组中,并在

- (NSArray *)eventsFrom:(NSDate *)fromDate to:(NSDate *)toDate

to return events from both native calendar and server events. 从本机日历和服务器事件中返回事件。

here is my implementation of the methood 这是我实现聚会的方式

- (NSArray *)eventsFrom:(NSDate *)fromDate to:(NSDate *)toDate
{
NSMutableArray *matches = [NSMutableArray array];
for (Meeting *meeting in events)
{
    if (IsDateBetweenInclusive(meeting.startDate, fromDate, toDate)){
        [matches addObject:meeting];
    }
}
if([arrServerEvents count]>0){
    [matches addObjectsFromArray:arrServerEvents];
}

return matches;
}

also you can see that here i have created a common Meeting class, which has properties of both Ekevent and my server Events. 您还可以看到这里我创建了一个通用的Meeting类,该类同时具有Ekevent和服务器事件的属性。 in changed the EKEvents to my common class object in the 在将EKEvents更改为我的普通类对象

- (void)presentingDatesFrom:(NSDate *)fromDate to:(NSDate *)toDate delegate:(id<KalDataSourceCallbacks>)delegate{

methood, and then added these objects to the native events array of the eventkitDatasource.m. 方法,然后将这些对象添加到eventkitDatasource.m的本机事件数组中。

hope I am clear enough. 希望我足够清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM