Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

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

thank you

like image 410
Mina Fawzy Avatar asked Nov 10 '22 00:11

Mina Fawzy


1 Answers

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

like image 56
Nick Wilkerson Avatar answered Nov 14 '22 22:11

Nick Wilkerson