Autogenerating GET url query string using the contents on the parameters dictionary #830

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

An easy way to change between GET and POST methods using the same code
structure. Depending the data on parameters and the httpMethod the property urlPath will display the correct url, filling with data the querystring (for GET requests) or the requestBody (for PUT/POST requests). Also added tests.

Starting with the TTURLRequest object:

TTURLRequest *request = [[TTURLRequest alloc] initWithURL:@"http://sample.com" delegate:nil];

If the parameters dictionary is empty, request.urlPath will show:

http://sample.com 

If we fill the parameters dictionary

NSDictionary* parameters = [NSDictionary dictionaryWithObjectsAndKeys:
                                @"value1", @"parameter1", @"value2", @"parameter2", nil];
[request.parameters addEntriesFromDictionary:parameters];

The method request.urlPath now will show:

http://sample.com?parameter2=value2&parameter1=value1

Using the same request object and changing httpMethod to POST or PUT, request.urlPath will show:

http://sample.com

And the parameters will be added to de requestBody

@brovador brovador TTURLRequest generate GET query from parameters
Autogenerating GET url query string using the contents on the
parameters dictionary.
Easy to change between GET and POST methods using the same code
structure.
d3a2a2b
Contributor

Facebook has not maintained or supported Three20 for some time, and we are closing its old and outstanding pull requests.

Many, many thanks for your support of the project. If you have any further questions, please don't hesitate to let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment