隐藏/显示UITableViewCell附件披露指标

S A*_*mik 36 iphone uitableview

我正在尝试从Core Data加载一个字符串,如果该行中的值等于" - ",则Accessory Disclosure Indicator将隐藏,并且单元格选择样式应该是SelectionStyleNone.

我尝试过这个,但没有成功

if (entity.value == @"--"){
    cell.selectionStyle = UITableViewCellSelectionStyleNone;  
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}  
Run Code Online (Sandbox Code Playgroud)

要么

NSString *this = entity.value;
if (this == @"--") {
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
Run Code Online (Sandbox Code Playgroud)

两者都没有工作,但这可能吗?谢谢.

Raf*_*nso 19

我认为问题在于比较表达式.正确的方法:

if ([entity.value isEqualToString:@"--"])
Run Code Online (Sandbox Code Playgroud)

要么

if ([this isEqualToString:@"--"])
Run Code Online (Sandbox Code Playgroud)