XCODE 5.0, сохраняя таблицы значений Mutable

Я постараюсь быть более понятным, предоставляя код. Цель состоит в том, чтобы получить информацию из списка. (заголовок и подзаголовок) и добавьте это в таблицу. Следующий код работает для меня, но не позволяет мне удалить любую из строк. Я пытаюсь найти способ сделать это.

#import "RWTViewController.h"
#import "details.h"

@interface RWTViewController () {
    NSMutableArray *titleSubject;
    NSMutableDictionary *subTitleContent;
}

@end

@implementation RWTViewController
NSInteger counter;

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    counter = subTitleContent.count;

    return counter;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath *) indexPath{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    // retreive image

    UIImage *myImage = [UIImage imageNamed:@"unreadMessage"];
    [cell.imageView setImage:myImage];

    cell.textLabel.text = titleSubject[indexPath.row];

    // This could possibly be changed?
    cell.detailTextLabel.text = subTitleContent[titleSubject[indexPath.row]];

    return cell;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:     (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Remove the row from data model
    [titleSubject removeObjectAtIndex:indexPath.row];



    // Request table view to reload
    [tableView reloadData];
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSURL *urlWeb = [[NSBundle mainBundle] URLForResource:@"messageinfo"       withExtension:@"plist"];
    subTitleContent = [NSDictionary dictionaryWithContentsOfURL:urlWeb];


    titleSubject = subTitleContent.allKeys; 
//this tells me incompatible pointer assigning nsmutablearray from array.. not sure if         there is another way to implement. 
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

2 ответа

Если я правильно понимаю ваш вопрос, то это должно сработать.

NSDictionary *dictionary = someInfo;

NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] initWithDictionary:dictionary];

Вы должны установить словарь в изменяемый словарь через alloc init, если вы только его создаете.

Попробуйте создать изменяемую копию словарных ключей:

NSMutableArray *mutablearray = moreDetails.allKeys.mutableCopy
Другие вопросы по тегам