• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: cocoa/Obj-C API for iCal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cocoa/Obj-C API for iCal


  • Subject: Re: cocoa/Obj-C API for iCal
  • From: DevReseune <email@hidden>
  • Date: Thu, 17 Jul 2003 18:15:09 +0200

There is a framework for that:
/System/Library/PrivateFrameworks/CALCore.framework

You can do all you want with it. It's easy except for synchronize with
iCal. I can't do it now. But, I just found this framework, so I
certainly do many mistakes

#import <Foundation/Foundation.h>

@class CALCalendarsDefaults;
@class CALRepositoryManager;
@class CALRFCFileRepository;
@class CALEntity;
@class CALEvent;
@class CALQuery;
@class CALDate;
@class CALCalendar;
@class CALCore;

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

int index;
int count;

CALRepositoryManager *manager2 = [CALRepositoryManager
defaultManager]; // to connect to iCal
NSDictionary *locaRepositories = [manager2 localRepositories]; //
to get all calendars

count = [locaRepositories count];
for (index = 0; index < count; index++) {
NSString *ID = [[locaRepositories allKeys] objectAtIndex:
index]; // to get calendard ID
CALRFCFileRepository *fileRepository = [manager2 repositoryWithKey:
ID]; // to get repository of calendars (file .ics)
[fileRepository load]; // if you don't do that, data
aren't initiated
NSLog(@"repository (ID: %@): %@", ID, [fileRepository name]); //
get the name
}

// search a calendar
CALRFCFileRepository *testFileRepository;
for (index = 0; index < count; index++) {
NSString *ID = [[locaRepositories allKeys] objectAtIndex: index];
testFileRepository = [manager2 repositoryWithKey: ID];
[testFileRepository load];
NSLog(@"repository (ID: %@): %@", ID, [testFileRepository name]);
if ([[testFileRepository name] isEqual: @"TEST"])
break;
else
testFileRepository = nil;
}

if (testFileRepository != nil) {
NSLog(@"repository TEST: %@ (%i)", testFileRepository,
[testFileRepository isWritable]);

CALCalendar *calendar = [testFileRepository storage]; // with it,
you can access to events, todos, ...

// ****** I TEST THIS CODE, SO... ******
CALEvent *newEvent = [CALEvent event];
[newEvent setSummary: @"my second event"];
CALDate *eventDate = [CALDate date];
//[eventDate addSecondsInGMT: 60*60*2];
[newEvent setStartDate: eventDate];
[newEvent setUID: @"ABCD-123456789-4"];
[newEvent commit]; // necessary?

[calendar addEntity: newEvent];
[calendar commit]; // necessary?
NSLog(@"save: %i", [testFileRepository _save]); // save to file
}


[pool release];
return 0;
}



> FROM: Stefan Pantke
> DATE: 2003-07-17 14:31
>
> ABAddressBook serves as programatically interface for Adress Book.
> Searching Apple's developer site, I could not find any API for
> iCal.
>
> Does iCal really has no programatically interface?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: cocoa/Obj-C API for iCal
      • From: John Randolph <email@hidden>
  • Prev by Date: Re: NSToolbar Acting as Tabs
  • Next by Date: Re: now it really gets weird
  • Previous by thread: Re: cocoa/Obj-C API for iCal
  • Next by thread: Re: cocoa/Obj-C API for iCal
  • Index(es):
    • Date
    • Thread