+ Start a Discussion
kyleRochekyleRoche 

[zksForce] multiple queries

hi... i'm working in iOS. it seems I can only have one call to client:query with a selector running at any time. if more than one are launched, my app is crashing. if i put them serially, everything is fine. 

 

is this just an iOS threading issue? is there a way to call multiple client.query methods with separate selectors in the same method? 

 

thanks! 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

This is definitely wrong, selectors are not strings. you want @selector(cuurrentFacilityQueryDidFinish:error:context:)

 

withSelector:@"currentFacilityQueryDidFinish:"

All Answers

SuperfellSuperfell

I assume you mean the ios toolkit, as there's no methods in zksforce that take a selector. Having said that, with the ios toolkit i was able to have 3 calls to query outstanding, and they all completed as expected. Was this on the simulator or the device, do you have a stack trace for the crash ?

kyleRochekyleRoche

Hi Simon, 

 

Yes, the iOS toolkit, apologies. Actually, zksforce's Results array worked fine for me running three methods in a row. 

 

With the iOS toolkit: 

Do you have to use different pointers or anything to use selectors? 

I start having issues w/ more than one selector running at a time. For example, two methods like: 

 

- (void)firstQueryDidFinish:(ZKQueryResult *)result;

- (void)otherQueryDidFinish:(ZKQueryResult *)result;

 

Any help is appreciated. Your three call example... is that source (just the selector signatures) you can share? 

 

Thanks! 

SuperfellSuperfell

 

-(void)query1Result:(ZKQueryResult *)r error:(NSError *)error context:(id)c {
	NSLog(@"Query1 returned %d rows", [r size]);
}

-(void)query2Result:(ZKQueryResult *)r error:(NSError *)error context:(id)c {
	NSLog(@"Query2 returned %d rows", [r size]);
}

- (void)loginResult:(ZKLoginResult *)result error:(NSError *)error
{		[[ZKServerSwitchboard switchboard] query:queryString target:self selector:@selector(query1Result:error:context:) context:nil];
		[[ZKServerSwitchboard switchboard] query:@"select count() from contact" target:self selector:@selector(query2Result:error:context:) context:nil];
}

 

I had something like

 

 

 

kyleRochekyleRoche

Interesting... I'll try w/out the delegates. I had trouble getting two of these to fire from the same method. 

 

 

[appManager.client query:[NSString stringWithFormat:@"SELECT Id,Facility__c FROM TT_Time_Log__c WHERE Id = '%@' limit 1",[appManager.contact fieldValue:@"Active_Time_Log__c"]]
	withDelegate:self
	withSelector:@"currentFacilityQueryDidFinish:"
	withErrorDelegate:nil
	withErrorSelector:nil];

 

Thanks Simon! Let me know if you notice anything else odd in this snippet. :) 

 

 

 

 

SuperfellSuperfell

This is definitely wrong, selectors are not strings. you want @selector(cuurrentFacilityQueryDidFinish:error:context:)

 

withSelector:@"currentFacilityQueryDidFinish:"
This was selected as the best answer
kyleRochekyleRoche

ha... **bleep**. sorry. must have been late when i did that. that sucks that it compiles and runs. it'll actually fire the selector from the string. but, just one of them. odd. 

 

thanks again Simon! 

kyleRochekyleRoche

odd word to bleep... it wasn't anything bad (for the record) :)