my app is coreData based, uses mapKit, and spot annotations. The app runs with all it's functionalities; the main issue is that when i input a new location on this text field, this new spot does not appear in the Table View like it should. Only when I restart the app, the table is refreshed and the new spot is available despite having the tableview reload instruction. Does anyone have a clue why this happens and how I can fix it? Thank you. The code for the table view:
@interface TableViewController ()
@property (strong) NSMutableArray *lisbonSpots;
@end
@implementation TableTableViewController
- (IBAction)delete:(UIBarButtonItem *)sender {
self.tableView.editing = !self.tableView.editing;
}
- (void)viewDidLoad {
[super viewDidLoad];
//_bar=[Spot spotType:@"bar"];
self.tableView.dataSource = self;
_lisbonSpots = [[Spot allSpots]mutableCopy];
NSLog(@"The Core Spots are: %@", _lisbonSpots);
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.lisbonSpots.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSManagedObject *ls = [self.lisbonSpots objectAtIndex:indexPath.row];
NSLog(@"Table Spots are: %@", ls);
[cell.textLabel setText:[NSString stringWithFormat:@"%@", [ls valueForKey:@"name"]]];
cell.imageView.image = [UIImage imageNamed:@"city.jpg"];
return cell;
}