简体   繁体   中英

iOS - how can i add events to kal library in Objective C?

I work in project need calendar view with events , i try many libraries but finally i decide to use kal library as its have ability to add events

Calendar.h

#import "Kal.h"
#import "NSDate+Convenience.h"
#import "EventKitDataSource.h"


@interface Calendar : UIViewController<WebService_Delegate , UITableViewDelegate >
{


    KalViewController *kal;
    id dataSource;
}

Calendar.m

- (void)viewDidLoad
{
    [super viewDidLoad];



    self.title = @"Caledar";
    kal = [[KalViewController alloc]initWithSelectionMode:KalSelectionModeSingle];
    kal.selectedDate = [NSDate dateStartOfDay:[NSDate date]];
     kal.delegate = self;


    kal.view.frame = CGRectMake(0, 65, kal.view.frame.size.width, kal.view.frame.size.height);

    [kal showAndSelectDate:[NSDate date]];
    //navController = [[UINavigationController alloc]initWithRootViewController:kal];
   // [self.view addSubview:navController.view];
    [self initVariable];
    [self getEvents];


    dataSource = [[EventKitDataSource alloc] init];
    kal.dataSource = dataSource;



   [self.view addSubview:kal.view];

}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    // Display a details screen for the selected event/row.
    EKEventViewController *vc = [[EKEventViewController alloc] init];

    vc.event = [dataSource eventAtIndexPath:indexPath];

    //[vc setEvent:[events_array objectAtIndex:indexPath.row]];
    vc.allowsEditing = NO;
    [navController pushViewController:vc animated:YES];
}

how can i pass data to dataSource to display it

here how its look like

在此输入图像描述

i need set events list to my events list , i got event duplicated , its read from my calendar

thank you

You need to implement the KalDataSource protocol in an object and set that object as the datasource of your kal object. The protocol can be found here https://github.com/klazuka/Kal/blob/master/src/KalDataSource.h

Add the KalDataSource protocol to your header file <WebService_Delegate , UITableViewDelegate, KalDataSource>

In the init method of your Calendar object set kal.datasource = self

Implement the KalDataSource methods in your object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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