+ Start a Discussion
NMISHRANMISHRA 

zksForceClient search method sample?

Hi,

 

  Is there a sample code snippet of using the search method of the zksForceClient when it returns objects of multiple types(like Account, Contact and others)? 

 

Thanks in advance and regards

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

You can't compare object points to compare string values, you need to use the isEqualToString: method on NSString. e.g. if ([[r type] isEqualToString:@"Contact"]) { // do something }

All Answers

SuperfellSuperfell
it returns an NSArray of ZKSObject instances, you can determine the salesforce type of each ZKSObject via the type getter
NMISHRANMISHRA

Thanks for quick response! A small sample code snippet will really help...

 

Regards

SuperfellSuperfell

NSArray *res = [client seach:someSosl];

for (ZKSObject *r in res) {

NSLog(@"result is a %@", [r type]);

}

SuperfellSuperfell
NMISHRANMISHRA

Thanks. I want to check the type of object whether it is a Contact, Account or any other. However, the following check fails:

 

if

( [r type] == @"Contact")

{

NSLog(@"%@", [ r valueForKey:@"Id"]);

}

 

even though I see the object is a Contact object in the XCode watch window.

 

May be I'm missing something simple...

SuperfellSuperfell

You can't compare object points to compare string values, you need to use the isEqualToString: method on NSString. e.g. if ([[r type] isEqualToString:@"Contact"]) { // do something }

This was selected as the best answer
NMISHRANMISHRA

That was it...thanks!

HoustonAPlusHoustonAPlus

Is it possible to use NSPredicate?

SuperfellSuperfell

Not directly, if you wanted a challenge you could write something to generate soql or sosl from an NSPredicate.