views:

173

answers:

1

In one of my project, I want to use the TTURLRequestModel to populate the response data in XML format by passing the TTURLXMLResponse to the request. However, the delegate method is never called. Can someone tell me what I am missing in these two files? Do I need to initialize some other elements of the library?

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);
}
+1  A: 

Hi,

Perhaps the request failed? You're only implementing the success method of the protocol - does request:didFailLoadWithError: get called instead?

I'd implement every method possible just for debugging to see what's going on. Then when you've got it working, remove the onls you don't need.

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!

deanWombourne
hi dean, thanks for your answer, I have tried to implement all the delegate methods as for testing purpose, but none of them is called. Even with an http or https, there's no difference. it's just silent.
sfa
What happens if you try 'http://www.google.com' as the URL? That should definately give a response!
deanWombourne
ohh thanks Dean, it's my fault. The request did get an error, so it asked the delegate - (void)request:(TTURLRequest *)request didFailLoadWithError:(NSError *)error instead. I always thought that the request url is right, recently there was change in the server. Some good notes: do implement all the error handling methods, if you override the super delegate methods then you should call the parent with [super didDOsth] methods.
sfa