3

I want to executue two or more SOQL queries from the ViewDidLoad method, e.g., return a particular list of customers, return a particular list of cases etc. How can this be done? I have experimented by trying to setup request1 variable and request2 variables but I get stuck when passing into request(SFRequest *)request didLoadResponse as I can only call this once. Below is the relevant pieces of code:

SFRestRequest *request1 = [[SFRestAPI sharedInstance] requestForQuery:@"SELECT Id, Name, Phone FROM Account"];
[[SFRestAPI sharedInstance] send:request1 delegate:self];

As far as I can see, this then gets passed on to

- (void)request:(SFRestRequest *)request didLoadResponse:(id)jsonResponse {
    NSArray *records = [jsonResponse objectForKey:@"records"];
    self.dataCustomerDetailRows = records;
    [self.tableCustomerList reloadData];

Can you outline a way of running the two queries and passing the results back into the two tableViews within the view?

5

One option is to keep a reference to the SFRestRequest objects you create and, in your response delegate method, determine which request has just completed and process accordingly.

A far better option, in my (not-so) humble opinion, is to use the nifty block interfaces I contributed to the SDK. :)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.