I will try to be more clear by providing code. The objective is to grab information from a plist. (a Title and a subtitle) and add this to a table. The following code works for me but does not allow me to delete any of the rows. I am trying to figure out a way to do this.
#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