在 Objective C 中访问日历事件 GData
我想知道是否有人知道如何在 Objective C 应用程序中访问谷歌日历中的数据。我正在尝试创建一个 iPhone 应用程序来访问数据、处理数据并以自定义格式显示数据。
我的项目文件中有源代码,它们编译得很好,但我在实际获取数据时遇到了困难。谁能帮我一些帮助。多谢!
更新:
好吧,我在谷歌的网站上发现了一个简单的东西,它给出了一些简单的解释,但是当我使用提供的代码时,我得到“SIGABRT”,
我确实相信错误在于 didFinishSelector:@selector(ticket: FinishWithFeed:错误:)。
在方法中处理设置一切。
ticket = [service fetchFeedWithURL:feedURL
delegate:self
didFinishSelector:@selector(ticket:finishedWithFeed:error:)];
didFinishSelector 方法如下,
- (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 was wondering if anyone knew how to access 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,另一个论坛上的某人帮助了我,并给了我以下解决方案,到目前为止它对我有效。尽管我确实注意到编辑完日历后您必须退出谷歌,否则它会因某种原因无法工作。
访问事件信息 GDATA< /a>
该论坛中没有说明的是您需要在接口文件中声明以下内容
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
CalendarSample 应用演示如何使用 Objective-C 库获取用户的日历和日历条目。
The CalendarSample application shows how to use the Objective-C library to fetch a user's calendars and calendar entries.