UITableViewCell accessoryType is not working

如題,不管Custom Cell或iOS原生的DefaultStyle Cell,都會發生accessoryType不管怎麼設定都無效的狀況,其實無關AutoLayout或XCode版本~
最需要注意的是,編輯狀態是否開啟!

假設某些row設定cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
當UITableView透過 setEditing:YES 開啟編輯狀態,UITableViewCellAccessoryDisclosureIndicator效果會因此不見,只剩下label text,且相對於UITableView的margin等layout呈現都會不同。

如果UITableView很複雜,想同時有編輯狀態又要保持accessoryType ,那麼就要仔細針對每個cell去設定編輯狀態,實際撰寫方式如下

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 1)
        return YES;
    else
        return NO;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.section == 1) {
        if(indexPath.row == [self.myData count])
            return UITableViewCellEditingStyleInsert;
        else
            return UITableViewCellEditingStyleDelete;
    } else {
        return UITableViewCellEditingStyleNone;
    }
}

Get/Set a BOOL in the NSDictionary

Objective-C containers can store only Objective-C objects so you need to wrap you BOOL in some object.

Here is the Dictionary
NSMutableDictionary *dictionary1 =[[NSMutableDictionary alloc]init];
[dictionary1  setObject:[NSNumber  numberWithBool:false]  forKey:@"MyBoolValue"];

How to set bool value ?
[dictionary1  setObject:[NSNumber  numberWithBool:false]  forKey:@"MyBoolValue"];

How to get bool value ?
BOOL myValue = [dictionary1  objectForKey:@"MyBoolValue"]  boolValue];