How to delete a calendar

14 views
Skip to first unread message

airwolf

unread,
Jan 14, 2011, 12:43:51 AM1/14/11
to Google Data APIs Objective-C Client Library Discussion
In my app, I am using Google Data APIs to sync data to Google
Calendar.

Now I want to delete a calendar in Google Calendar, what I am using
now is:

- (void)deleteCalendar:(GDataEntryCalendar *)calendar {

if ([[calendar editLink] URL] != nil) {

[calendar setIsSelected:YES];

GDataServiceGoogleCalendar *service = [self calendarService];

[service deleteResourceURL:[[calendar editLink] URL] ETag:[calendar
ETag] delegate:self
didFinishSelector:@selector(deleteCalendarTicket:deletedEntry:error:)];

}

}

But this code did not work T_T

This is my first project using GData framework, and I did some search
on this but no result.

-Airwolf

Greg Robbins

unread,
Jan 14, 2011, 10:41:57 AM1/14/11
to gdata-objec...@googlegroups.com
The method deleteSelectedCalendar in the CalendarSample application shows how to delete a calendar using the service deleteEntry: method, given the calendar's entry from the owned calendars feed (kGDataGoogleCalendarDefaultOwnCalendarsFeed).

http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#RetrievingOwnCalendars

airwolf

unread,
Jan 14, 2011, 11:08:10 AM1/14/11
to Google Data APIs Objective-C Client Library Discussion
Hi Greg,
Thanks for your reply :)

I've tried that deleteEntry: method just now, but there's still some
problem

my code is like this:

- (void)deleteTargetCalendar {

NSURL *editURL = [[[self selectedCalendar] editLink] URL];

if (editURL != nil) {

GDataServiceGoogleCalendar *service = [self calendarService];

[service deleteEntry:[self selectedCalendar]
delegate:self

didFinishSelector:@selector(deleteCalendarTicket:deletedEntry:error:)];
}

}

And I used the selectedCalendar method as well. But the calendar to
delete, it's editLink is always nil ......
> http://code.google.com/apis/calendar/data/2.0/developers_guide_protoc...

Greg Robbins

unread,
Jan 14, 2011, 11:24:11 AM1/14/11
to gdata-objec...@googlegroups.com
Lack of an edit link indicates that the entry is coming from feed for which the authenticated user does not have write permissions. Not all calendar feeds allow the user to edit entries. The owncalendars feed specifically is for getting the editable calendar entries.

airwolf

unread,
Jan 14, 2011, 12:16:49 PM1/14/11
to Google Data APIs Objective-C Client Library Discussion
Thanks for your reply ^_^

Well, I just tried using the same account to create a new calendar
then to delete this one, but it's editLink is still nil ......

Very strange thing ...

By the way, here's my code for creating new calendar

- (void)addCalendar {

GDataServiceGoogleCalendar *service = [self calendarService];

GDataEntryCalendar *newEntry = [GDataEntryCalendar calendarEntry];
[newEntry setTitleWithString:@"New Event List"];
[newEntry setIsSelected:YES];
[newEntry setColor:[GDataColorProperty valueWithString:@"#2952A3"]];

[service fetchEntryByInsertingEntry:newEntry
forFeedURL:[NSURL URLWithString:@"http://www.google.com/
calendar/feeds/default/owncalendars/full"]
delegate:self

didFinishSelector:@selector(addCalendarTicket:addedEntry:error:)];

}

Is there something wrong?

Greg Robbins

unread,
Jan 14, 2011, 4:50:15 PM1/14/11
to gdata-objec...@googlegroups.com
A nil edit link would be due to the calendar entry being taken from a feed which lacks edit permission, or the entry being created from scratch rather than taken from an appropriate feed.

I can't really guess what may be going wrong without seeing the code that fetches the feed and obtains the entry. I suspect the feed being fetched is the user's allcalendars feed.

airwolf

unread,
Jan 14, 2011, 10:14:27 PM1/14/11
to Google Data APIs Objective-C Client Library Discussion
Thanks, Greg :)

When I am using this URL to add new calendar:
https://www.google.com/calendar/feeds/default/owncalendars/full
It is working, but this calendar is lacking of edit link;

But if I choose to use [[mCalendarFeed postLink] URL] as the Google
Calendar Sample did, it failed with error something like "This feed is
read-only" ......

Really really confused >_<

Greg Robbins

unread,
Jan 14, 2011, 11:54:49 PM1/14/11
to gdata-objec...@googlegroups.com
Again, without seeing your code, I cannot really say what may be going wrong.

Are you using a fetched version of the calendar entry? Those may have edit links; calendar entries made by the application will not.

Can you delete the calendar you create using the CalendarSample application?
Reply all
Reply to author
Forward
0 new messages