Sam Soffes
Sam Soffes

Reputation: 14935

TTURLResponse is nil

I am trying to implement a simple TTURLRequest in my app. I'm pretty new to the Three20 framework. I mainly want TTURLRequest and TTImageView for the awesome caching stuff.

I have the following code in my delegate:

- (void)requestDidFinishLoad:(TTURLRequest*)request {
    TTURLDataResponse *response = request.response;
    // Stuff to process response.data
}

response is always nil. I can't figure out what I'm doing wrong. I looked in the Application Support directory and it's creating the cache file with the proper data, so I know it's getting a response. What am I doing wrong?

Upvotes: 3

Views: 2061

Answers (2)

Steve Brewer
Steve Brewer

Reputation: 2100

Debugged your code - you actually have to create a response object and add it to the request before sending your request:

NSString *url = @"http://twitter.com/statuses/user_timeline/samsoffes.json?count=1";
TTURLRequest *theRequest = [[TTURLRequest alloc] initWithURL:url delegate:self];
theRequest.response = [[[TTURLDataResponse alloc] init] autorelease];
[theRequest send];

One would think the request would be in charge of creating the response, but the Three20 stuff doesn't.

Upvotes: 6

Reputation:

Mark Allen from revetkn.com posted a datasource implementation for TTURLRequest.

He also posted an example project where he assumes you have Three20 installed at ../ (relative to your project). It's here: http://revetkn.com/?p=72

Upvotes: 0

Related Questions