Invalid operand to binary +

519
2
07-14-2010 01:35 PM
AkhlaqRao
New Contributor
Hi,

I am getting this invalid operand to binary error when I am trying to pass Parcel ID from a text box casted into an integer. Although, I do not need to convert its cast into integer, but I am not sure how can I compare searchBar.text value with "Title_Lookup" fieldAliases?

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
parcelsQuery = [AGSQuery query];
NSString *start = searchBar.text;
int startValue = [start integerValue];
parcelsQuery.where = @"Title_Lookup = '" +startValue+ "'";
parcelsQuery.outFields = [NSArray arrayWithObject:@"*"];
[parcelsQueryTask executeWithQuery:parcelsQuery];

[searchBar resignFirstResponder];
[AGSMapView showNetworkActivityIndicator:YES];
}

On the other hand this code (below) does not throw any exception nor the results?

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
parcelsQuery = [AGSQuery query];
parcelsQuery.where = @"Title_Lookup = 'searchBar.text'";
parcelsQuery.outFields = [NSArray arrayWithObject:@"*"];
[parcelsQueryTask executeWithQuery:parcelsQuery];

[searchBar resignFirstResponder];
[AGSMapView showNetworkActivityIndicator:YES];
}

Only this code (below) shows me the result, but I want to pass the Parcel ID dynamically right out of text box casted or without casted..any help will do it.
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
parcelsQuery = [AGSQuery query];
parcelsQuery.where = @"Title_Lookup = '0022884928'";
parcelsQuery.outFields = [NSArray arrayWithObject:@"*"];
[parcelsQueryTask executeWithQuery:parcelsQuery];

[searchBar resignFirstResponder];
[AGSMapView showNetworkActivityIndicator:YES];
}

Akhlaq Rao
GeoSurfInc.
0 Kudos
2 Replies
NimeshJarecha
Esri Regular Contributor
Try changing your code like this and see if it works..

parcelsQuery = [AGSQuery query];
NSString *start = searchBar.text;
//int startValue = [start integerValue];
//parcelsQuery.where = @"Title_Lookup = '" +startValue+ "'";
parcelsQuery.where = [@"Title_Lookup=" stringByAppendingString:start];
parcelsQuery.outFields = [NSArray arrayWithObject:@"*"];
[parcelsQueryTask executeWithQueryarcelsQuery];

Regards,
Nimesh
0 Kudos
AkhlaqRao
New Contributor
Hi Nimesh,

Thanks, yeah I fixed it yesterday. Since I came from .Net and didn't know that I need to buildup the string with format before I pass it as a parameter. I've done almost the same thing as you did the code as follow.

parcelsQuery = [AGSQuery query];
self.parcelsQuery.where = [NSString stringWithFormat:@"Title_Lookup = '%@'", self.parcelsQuery.text = searchBar.text];
[parcelsQueryTask executeWithQuery:self.parcelsQuery];


Regards
Akhlaq Rao
GeoSurfInc.

Try changing your code like this and see if it works..

parcelsQuery = [AGSQuery query];
NSString *start = searchBar.text;
//int startValue = [start integerValue];
//parcelsQuery.where = @"Title_Lookup = '" +startValue+ "'";
parcelsQuery.where = [@"Title_Lookup=" stringByAppendingString:start];
parcelsQuery.outFields = [NSArray arrayWithObject:@"*"];
[parcelsQueryTask executeWithQueryarcelsQuery];

Regards,
Nimesh
0 Kudos