0

在我的一个项目中,我想使用 TTURLRequestModel 通过将 TTURLXMLResponse 传递给请求来填充 XML 格式的响应数据。但是,从不调用委托方法。有人可以告诉我这两个文件中缺少什么吗?我是否需要初始化库的其他一些元素?

Three20Parser.h

@interface Three20Parser : TTURLRequestModel{

}

- (void) download;

@end

Three20Parser.m

#import "Three20Parser.h"
#import "extThree20XML/extThree20XML.h"

@implementation Three20Parser

- (id)init{
    self = [super init];
    return self;
}

- (void) download{
    NSString *requestURL = @"http://server.local/service.asmx";
    NSLog(@"requestURL: %@", requestURL);

    TTURLRequest *request = [TTURLRequest requestWithURL:requestURL delegate:self];
    request.cacheExpirationAge = TT_CACHE_EXPIRATION_AGE_NEVER;
    request.cachePolicy = TTURLRequestCachePolicyNone;

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

    [request send];
}

     /*
 the requestDidFinishLoad is not called.
 */

- (void)requestDidFinishLoad:(TTURLRequest *)request{
    //TTURLXMLResponse *response = request.response;
    //NSLog(@"response: %@", [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]);

    NSLog(@"REQUEST DID FINISH", nil);
}
4

1 回答 1

1

也许请求失败了?您只是在实现协议的成功方法- request:didFailLoadWithError: 是否被调用?

我会实现所有可能的方法,只是为了调试以查看发生了什么。然后当你让它工作时,删除你不需要的唯一。

However, you should always check for errors - you might have to tell the user it has failed for Apple to allow the app into the app store! Even if you don't have to tell the user, you should probably do something about it!

于 2010-05-27T09:35:28.317 回答