如何制作iOS版Facebook messenger之类的UITableViewCell文本?

如何制作iOS版Facebook messenger之类的UITableViewCell文本?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,当我们在FacebookMessenger上收到一条消息时,触摸该单元格并查看该消息后,文本在UITableViewCell中变为粗体,然后返回UITableView,该单元格文本不再为粗体 如何创建此行为 下面是我的代码: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ . . . //Implementation . . . [[fetchedObje

当我们在FacebookMessenger上收到一条消息时,触摸该单元格并查看该消息后,文本在UITableViewCell中变为粗体,然后返回UITableView,该单元格文本不再为粗体

如何创建此行为

下面是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
.
.
.
//Implementation
.
.
.

 [[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

.
.
.

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;
    }
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath{
.
.
.
//实施
.
.
.
[[fetchedObjects objectAtIndex:indexath.row]setValue:@“1”forKey:@“lido”];
n错误*错误;
//Escreve no banco a alteração
[上下文保存:&错误];
对于(int index=0;index
  • 模型对象应存储消息是否已读的状态。消息未读时,
    单元格
    应以粗体显示文本。当状态更改时,重新加载
    单元格
    ,并让其根据此状态自行配置

  • 这是一种非常常见的模式。在尝试实现它时,您是否遇到了一些特殊的困难


问题在于
核心数据
@“lido”
中的数据类型。对于
核心数据
@“lido”
字段中的类型,是字符串,我正在与
IF()
中的
INT
进行直接比较

cellforrowatinexpath:

if ([[arrayProcessosLocal objectAtIndex: indexPath.row] valueForKey: @ "read"] == 1) {
. 
. 
. 
// Other implementation
正确的代码

if ([[[arrayProcessosLocal objectAtIndex: indexPath.row] valueForKey: @ "read"] isEqual: @ "1"]) {
. 
. 
. 
// Other implementation

Xcode无法知道来自
核心数据的数据类型,并且在运行时没有问题,因为
字符串
类型与
if()
,等于数值,然后要进行正确的验证,必须使用方法
isEqual:

是的,我有一个存储持久性到sabe消息状态,当选择单元格时,她是标记如何在数据存储中读取,但我如何实现单元格?如果你有代码示例,这将有帮助!我创建了一个代码,我使用了“if()'对于'CellForRowatineXpath:'中未读的detect属性,但这没有做更改。嘿,我发布了我的代码!看看并说出我做错了什么。好的,我将发布代码…嘿!我发布了代码!!