In my application there is a tableView & a search bar.
I have an NSMutable array to fill data in tableView.
Now, whatever user types in a search bar - data should be filter accordingly & tableView should be reloaded.
I have implemented following code in my application on textField resignFirstResponder.
My question is within this code.
-(BOOL)textFieldShouldReturn:(UITextField*)txt
{
[txt resignFirstResponder];
// on textfield resign searchData will be called
[self searchData];
return YES;
}
-(void)searchData
{
// N -> total elements & i for loop
NSInteger n=[CategoryDtlArray count],i;
//CategoryDtl is my custom class & it's objects are stored in my array
CategoryDtl *tmpCat;
// dtl string -> which is needed for comparison
NSString *dtl;
for (i=0; i<n; i++)
{
// got the object from array
tmpCat=(CategoryDtl*)[CategoryDtlArray objectAtIndex:i];
// got the description from the object for comparison
dtl=[NSString stringWithString:tmpCat.Tip_Description];
// string to search
NSString *strSrch=[NSString stringWithString:txtSearch.text];
// now I don't know how to check my object's String
// is starting with search string or not?
// if it starts with search string -> it should be displayed in table
// else not.
// "How to implement this?"
// String comparison without case sensitivity
}
}
Thanks in advance for helping me.