使用 Three20 拖动刷新来实现 Feed;不更新

发布于 2024-11-25 21:53:48 字数 1102 浏览 0 评论 0原文

我正在实现一个 Feed 项目,基本上使用 Three20 Twitter 示例作为我的参考,但使用我自己网站的 api 来获取 XML 响应。

我已经有了允许自己发布、删除 feed 的功能,但是当我拖动刷新 TTTableViewController 时,它不会更新表中的数据,它所做的是,它返回到我第一次加载表的状态。

我将始终获得来自第一个 XML 响应的数据。

- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more {
if (!self.isLoading && TTIsStringWithAnyText(_apiKey) && TTIsStringWithAnyText(_sessionKey)) {
    if(more) {
        _pageNumber++;
    }
    else {
        _pageNumber = 1;
        _finished = NO;
        [_feeds removeAllObjects];
    }

    NSString* url = @"api.mySiteHereWithParameters.com"
    TTURLRequest* request = [TTURLRequest requestWithURL: url delegate: self];

    request.cachePolicy = cachePolicy | TTURLRequestCachePolicyEtag;
    request.cacheExpirationAge = TT_CACHE_EXPIRATION_AGE_NEVER;

    TTURLXMLResponse* response = [[TTURLXMLResponse alloc] init];
    response.isRssFeed = YES;
    request.response = response;
    TT_RELEASE_SAFELY(response);

    [request send];
}

基本上,

当我拖动和刷新时,它会被调用,它会返回到 TTListDatasource 并更新表视图,其他所有内容都由 Three20 框架处理

I'm implementing a Feed Project basically using Three20 Twitter sample as my reference but using my own website's api to get XML response..

I have already functions that will allow myself to post, delete feeds, but when I drag to refresh the TTTableViewController, it does not update the data in the table, what it does is, it goes back to the state where I first loaded the table.

The data from the first XML response is what I will always get.

- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more {
if (!self.isLoading && TTIsStringWithAnyText(_apiKey) && TTIsStringWithAnyText(_sessionKey)) {
    if(more) {
        _pageNumber++;
    }
    else {
        _pageNumber = 1;
        _finished = NO;
        [_feeds removeAllObjects];
    }

    NSString* url = @"api.mySiteHereWithParameters.com"
    TTURLRequest* request = [TTURLRequest requestWithURL: url delegate: self];

    request.cachePolicy = cachePolicy | TTURLRequestCachePolicyEtag;
    request.cacheExpirationAge = TT_CACHE_EXPIRATION_AGE_NEVER;

    TTURLXMLResponse* response = [[TTURLXMLResponse alloc] init];
    response.isRssFeed = YES;
    request.response = response;
    TT_RELEASE_SAFELY(response);

    [request send];
}

}

Basically when I drag and refresh, this is called and it goes back down to TTListDatasource and updates the table view, everything else is handled with three20 framework

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

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

发布评论

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

评论(1

明媚如初 2024-12-02 21:53:48

应该是缓存的问题吧我发现您正在使用 etag 进行缓存。你的服务器支持吗?它必须在服务器端启用和配置。

尝试使用标准缓存:

request.cachePolicy = cachePolicy;
request.cacheExpirationAge = TT_DEFAULT_CACHE_EXPIRATION_AGE;

It's probably a cache issue. I see you're using etags to cache. Does your server support that? It has to be enabled and configured on the server side.

try to use the standard caching:

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