views:

63

answers:

1

Hello,

I have a question, (Basically same as this one which remained UN-answered

I'm writing some methods that call a JSON API, and receive a response, each method will create an HTTPRequest, but the data received will not be available in the method, but will be available in connectionDidFinishLoading.

How can i use the data now? I have different methods, each one receive something else, but i cannot control the data received because it's inside connectionDidFinishLoading.

i.e.

login (perform HTTPRequest)

getCustomerId (perform HTTPRequest)

getTextsforCustomer (perform HTTPRequest) ... ...

i want to do some actions with the JSON response already in the login/getCustomerId... methods.

Hope it's clear.

Thanks in advance.

Dror.

A: 

How about storing those values somewhere. Like in instance variables of a common object?

St3fan
but inside connectionDidFinishLoading i just get the data, one time it can be boolean value, one time it could be a whole bunch of JSON string, in anyways, i will eventually have tens of services, tens of methods that will perform tens of HTTPRequests, i don't think the connectionDidFinishLoading is the correct place to receive them all and start instancing variables... any other ideas?
Dror Sabbag
You could create separate objects for your requests, each with their own http request. And then let those objects store the results in some central object that they reference. Or give them delegates that are called on some central controlling object.
St3fan