Reputation: 432
I have array which contains Name, image url and many values, and i want to change image when searching result. here only changing name values. so how to add image value in array?
if (searchText.text.length == 0) {
isSearching = NO;
}
else
{
isSearching = YES;
filterdResult = [[NSMutableArray alloc]init];
for (NSString *str in [SQLData valueForKey:@"Name"]){
NSRange heroRange = [str rangeOfString:searchText.text options:NSCaseInsensitiveSearch];
if (heroRange.location != NSNotFound) {
[filterdResult addObject:str];
}
}
}
Here, SQLData is a NSMutableArray and it contains JSON Values, like name imageURL, but here it only add Name value, how can i add imagevalue too?
Upvotes: 0
Views: 42
Reputation: 2287
What is the structure of SQLData ? is it holds all the records ? You need to loop each RECORD and not each NAME.
this way, when you get ONE RECORD, you check the NAME field in that RECORD if the NAME value is rangeOfString:searchText.text THEN you add the RECORD to the filterResults.
this way you got filter array of RECORDS. in every RECORD you will have all the values you need (name, image and others)
RECORD can be for example NSDictionary ("name":nameValue, "imageURL":imageURLValue..etc). again I don't know exactly what SQLData holds, but I hope this give you the direction of what you are looking for.
Upvotes: 1