Access Calendar Events GData in Objective C
I was wondering if anyone knew how to ac开发者_如何学Gocess data from a google calendar in an objective c application. I am trying to create an iPhone application that access the data, process it and display it in a custom format.
I have the sources in the project file and they are compiling fine, but I am having trouble actually getting the data. Can anyone lend me some help. Thanks a lot!
UPDATE:
Alright, I found a simple thing on google's website that gives a brief explanation of stuff, however when I go to use the code provided I get "SIGABRT"
I do believe the error is lying in the didFinishSelector:@selector(ticket:finishedWithFeed:error:).
In method to handle setting everything up.
ticket = [service fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
The didFinishSelector method is as follows
- (void)ticket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedCalendar *)feed
error:(NSError *)error {
if (error == nil) {
NSArray *entries = [feed entries];
if ([entries count] > 0) {
GDataEntryCalendar *firstCalendar = [entries objectAtIndex:0];
GDataTextConstruct *titleTextConstruct = [firstCalendar title];
NSString *title = [titleTextConstruct stringValue];
NSLog(@"first calendar's title: %@", title);
} else {
NSLog(@"the user has no calendars");
}
} else {
NSLog(@"fetch error: %@", error);
}
}
I get an error every time it tries to access this method. Does anyone have an idea why?
Alright someone on another forum helped me out and gave me the following solution and it is working thus far for me. Though I did notice you have to log out of google once you are done editing a calendar or it will not work for some reason.
Accessing Event Information GDATA
What is not stated in that forum is that you will need to declare the following in the interface file
@property (nonatomic, retain) NSArray *calendarEvents;
@property (nonatomic, retain) GDataEntryCalendar *googleCalendar;
The CalendarSample application shows how to use the Objective-C library to fetch a user's calendars and calendar entries.
精彩评论