How do I create a UITableView
, where cells keep the text bold, until they are touched, and save this change?
For example, when we receive a message in Facebook, the text in UITableViewCell
is in bold, after touching the cell and seeing and returning to UITableView
, the cell text is no longer in bold type.
Example, Image Below:
Below is the code I tried, but it did not work:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
.
.
.
//Implementation
.
.
.
// Atualiza o estado de NÃO LIDO para LIDO no banco de dados
[[fetchedObjects objectAtIndex:indexPath.row ] setValue:@"1" forKey:@"lido"];
NSError*error;
// Escreve no banco a alteração
[context save:&error];
for (int index = 0; index<[fetchedObjects count]; index++) {
NSLog(@"%@",[[fetchedObjects objectAtIndex:index]valueForKey:@"lido"]);
.
.
.
// Implementation
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
.
.
.
//Implmentation
.
.
.
//Verifica o estado e faz a alteração na fonte da célula
if ([[arrayProcessosLocal objectAtIndex:indexPath.row ] valueForKey:@"lido"] == 1) {
//Torna fonte bold
cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
[cell.textLabel setText:[NSString stringWithFormat:@"%@ - %@", [processosLocal valueForKey:@"processo"],[processosLocal valueForKey:@"data_pdf"]]];
return cell;
}else{
// Exibe a fonte normal caso o valor de "lido" seja 0 (zero)
[cell.textLabel setText:[NSString stringWithFormat:@"%@ - %@", [processosLocal valueForKey:@"processo"], [processosLocal valueForKey:@"data_pdf"]]];
return cell;
}
How to do this process?