Hi i received 2000 of datas from udp and display the values in tableview .What is the easiest method to do this ?
Now i am using Two nsthreads and one thread for receive data via udp and stores it in NSMutableDictionary.Another thread update the tableview using these Dictionary values. But it crashes my app.
Here is some code i used
I stored Received values like this
NSMutableDictionary *dictItem
CustomItem *item = [[CustomItem alloc]init];
item.SNo =[NSString stringWithFormat:@"%d",SNo];
item.Time=CurrentTime;
[dictItem setObject:item forKey:[NSString stringWithFormat:@"%d",SNo]];
[item release];
Delegate method i used and i used CustomTableCells to display data as column vice.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dictItem count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"CustomTableCell";
CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[[CustomTableCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
}
NSArray *keys = [dictItem allKeys];
CustomItem *item = [dictItem objectForKey:[keys objectAtIndex:indexPath.row]];
cell.SNo.text = item.SNo;
cell.Time.text = item.Time;
return cell;
}
The errror is
Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection was mutated while being enumerated.' 2010-07-23 02:33:07.891 Centrak[2034:207] Stack: ( 42162256, 43320108, 42161198, 43372629, 41719877, 41719345, 9948, 3276988, 3237662, 3320232, 3288478, 71153942, 71153189, 71096786, 71096114, 71296742, 41650770, 41440069, 41437352, 51148957, 51149154, 2925426 ) terminate called after throwing an instance of 'NSException'
Can anyone help me ?
Thanks in advance.......