GData日历执行顺序

发布于 2024-11-09 03:44:37 字数 1705 浏览 5 评论 0原文

我想知道是否有人对这个问题有解释/解决方案。我正在使用 GData API 获取日历信息并将其存储到 NSDictionary 中,并稍后访问它。但是,当我调用该函数来获取数据时,似乎在调用该函数后很多行都发生了日历访问。

在下面的代码中,我立即调用 loadGoogleCalendarEvents,它会获取事件并进行更多处理,但我的应用程序“跳过”了它,添加按钮并执行我在其后面放置的其他操作,然后再获取日历东西。

有人对此有解释吗?

- (void)viewDidLoad
{    

    self.dayDictionary = [NSMutableDictionary dictionary];
    [self loadGoogleCalendarEvents];

    UIImage* fImage = [UIImage imageNamed:@"facebook_med"];
    CGRect fbuttonFrame = CGRectMake(220, 9, 25, 25);
    UIButton* fButton = [UIButton buttonWithType:UIButtonTypeCustom];
    fButton.frame = fbuttonFrame;
    [fButton addTarget:self action:@selector(pushFacebookButton) forControlEvents:UIControlEventTouchUpInside];
    [fButton setBackgroundImage:fImage forState:UIControlStateNormal];
    [fButton setShowsTouchWhenHighlighted:YES];

    UIImage* tImage = [UIImage imageNamed:@"twitter_med"];
    CGRect tbuttonFrame = CGRectMake(255, 9, 25, 25);
    UIButton* tButton = [UIButton buttonWithType:UIButtonTypeCustom];
    tButton.frame = tbuttonFrame;
    [tButton addTarget:self action:@selector(pushTwitterButton) forControlEvents:UIControlEventTouchUpInside];
    [tButton setBackgroundImage:tImage forState:UIControlStateNormal];
    [tButton setShowsTouchWhenHighlighted:YES];

    UIButton* aButton = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
    aButton.frame = CGRectMake(285,9, 25, 25);
    [aButton addTarget:self action:@selector(pushAboutButton) forControlEvents:UIControlEventTouchUpInside];
    [aButton setShowsTouchWhenHighlighted:YES];


    [navBar addSubview:fButton];
    [navBar addSubview:tButton];
    [navBar addSubview:aButton];

    [super viewDidLoad];
}

I was wondering if anyone had an explanation/solution for this problem. I am using the GData API to get calendar information and store it into an NSDictionary, and accessing it later. However when I call the function to get the data, it seems as if the calendar access is happening many lines after I call the function.

In the code below, I immediately call the loadGoogleCalendarEvents, which goes and gets the events and does some more processing, but my application is "jumping" past that, adding the buttons and doing whatever else I put after it, before it gets the calendar stuff.

Does anyone have an explanation for this?

- (void)viewDidLoad
{    

    self.dayDictionary = [NSMutableDictionary dictionary];
    [self loadGoogleCalendarEvents];

    UIImage* fImage = [UIImage imageNamed:@"facebook_med"];
    CGRect fbuttonFrame = CGRectMake(220, 9, 25, 25);
    UIButton* fButton = [UIButton buttonWithType:UIButtonTypeCustom];
    fButton.frame = fbuttonFrame;
    [fButton addTarget:self action:@selector(pushFacebookButton) forControlEvents:UIControlEventTouchUpInside];
    [fButton setBackgroundImage:fImage forState:UIControlStateNormal];
    [fButton setShowsTouchWhenHighlighted:YES];

    UIImage* tImage = [UIImage imageNamed:@"twitter_med"];
    CGRect tbuttonFrame = CGRectMake(255, 9, 25, 25);
    UIButton* tButton = [UIButton buttonWithType:UIButtonTypeCustom];
    tButton.frame = tbuttonFrame;
    [tButton addTarget:self action:@selector(pushTwitterButton) forControlEvents:UIControlEventTouchUpInside];
    [tButton setBackgroundImage:tImage forState:UIControlStateNormal];
    [tButton setShowsTouchWhenHighlighted:YES];

    UIButton* aButton = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
    aButton.frame = CGRectMake(285,9, 25, 25);
    [aButton addTarget:self action:@selector(pushAboutButton) forControlEvents:UIControlEventTouchUpInside];
    [aButton setShowsTouchWhenHighlighted:YES];


    [navBar addSubview:fButton];
    [navBar addSubview:tButton];
    [navBar addSubview:aButton];

    [super viewDidLoad];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷→糖丶微凉 2024-11-16 03:44:37

iOS 上的网络操作通常是异步的。使用 GData API 实际获取数据发生在开始获取的调用返回后很长时间。

日历事件加载完成后需要执行的任何任务都应在 GData 获取的回调中完成。一旦提取完成(或失败),将从应用程序的运行循环中调用回调。

Network operations on iOS are typically asynchronous. The actual fetch of data with the GData API occurs long after the call to begin the fetch has returned.

Any tasks that need to be performed after the load of calendar events has completed should be done in the callback from the GData fetch. The callback will be invoked from the application's run loop once the fetch has finished (or failed.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文