При добавлении объектов в NSArray или NSDictionary мое приложение отображает только копию последней записи.
Я получаю данные и отправляю их наблюдателю ...
[[NSNotificationCenter defaultCenter] postNotificationName:@"xmlFinishedLoading" object:self userInfo:[NSDictionary dictionaryWithObject:currentEventObject forKey:@"notifKey"]];
Этот код запускается, когда наблюдатель получает уведомление ...
-(void)populateCurrentEventsTableView:(NSDictionary *)events
{
NSDictionary *info = [events valueForKey:@"userInfo"];
Event *evt = [info valueForKey:@"notifKey"];
if (self.eventDictionary == nil) {
self.eventDictionary = [[NSMutableDictionary alloc]init];
}
[self.eventList addObject:evt];
NSString *key = [NSString stringWithFormat:@"%i",[eventList count] - 1];
[self.eventDictionary setValue:evt forKey:key];
NSLog(@"events description = %@",evt.eventDescription);
[self.tableView reloadData];
}
TableView перезагружен с этим кодом ...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ActivitiesList";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSUInteger row = [indexPath row];
NSString *rowKey = [NSString stringWithFormat:@"%i",row];
Event *evt = [eventDictionary objectForKey:rowKey];
cell.textLabel.text = evt.eventDescription;
cell.detailTextLabel.text = evt.eventSecondaryDescription;
return cell;
}
NSLog, который отображает описание события, в порядке, он показывает разные записи по мере их поступления. Однако, если бы я должен был отобразить записи eventDictionary, он показывает ту же запись. Любая помощь?