This may be a duplicate of many existing issues, one of which is:
This
or other links I've been looking for so far.
I am working on an application in which I display user information such as Location, Name, Image, Gender, Phone Number, etc.
I get this data through xmls. From parsing, I submit my NSMutableArray and show the details in the table view.
I want to apply a search in the NAME of a user in this array.
How do I get the names of people from them?
Here is the code I'm using:
To display information in a table:
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCellDetail" owner:self options:nil];
id firstObject =[topLevelObjects objectAtIndex:0];
if ( [ firstObject isKindOfClass:[UITableViewCell class]] )
cell = (CustomCellDetail *)firstObject;
ParsingItem *item=[self.arrayPeoples objectAtIndex:indexPath.section];
cell.lblUserName.text=[item.mdictXMLTagsData valueForKey:@"UserName"];
cell.lblStatus.text=[item.mdictXMLTagsData valueForKey:@"StatusMessage"];
cell.lblAge.text=[item.mdictXMLTagsData valueForKey:@"Gender"];
and to get the results, I found that only a string can be searched from an nmutable array, so I applied the search as follows:
-(void)FetchSearcheRecordsFromArray
{
self.filteredArray = self.arrayPeoples;
NSLog(@"string :%@",strSearchingText);
NSPredicate *Predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",self.strSearchingText];
NSLog(@"string :%@",Predicate);
[self.filteredArray filterUsingPredicate:Predicate];
NSLog(@"Array count is : %d",[self.filteredArray count]);
if ([self.filteredArray count] <= 0 )
{
self.lblNoRecordsFound.hidden = NO;
}
else
{
self.lblNoRecordsFound.hidden = YES;
}
[self.tblViewPeople reloadData];
}
My Application Crashes on line:
[self.filteredArray filterUsingPredicate:Predicate]
, , .
, , .
?
?
, , , .
, !