I was trying to see if a UITableView
cell contains a string.
I have tried using:
if ([cell.textlabel.text rangeOfString:@"Ok"].location !=NSNotFound)
{
}
But that was no use. It found the text every time no matter what.
I was trying to see if a UITableView
cell contains a string.
I have tried using:
if ([cell.textlabel.text rangeOfString:@"Ok"].location !=NSNotFound)
{
}
But that was no use. It found the text every time no matter what.
You should test if the cell.textlabel.text
string is not nil
. I've tested your code with a nil
value and always returns TRUE
.
if(cell.textlabel.text)
{
if ([cell.textlabel.text rangeOfString:@"Ok"].location !=NSNotFound)
{
...
}
}
Try like this below:-
NSString *str=cell.textlabel.text;
if ([str rangeOfString:@"Ok"].location !=NSNotFound)
{
}