Adding Rows to a Table View
Adding Rows to a Table View
- Subject: Adding Rows to a Table View
- From: Dave <email@hidden>
- Date: Wed, 31 Mar 2010 19:52:05 +0100
Hi All,
I have a UITableView object that starts out empty and then is
gradually added to via data coming from a URL.
Everything seems to be setup ok, the "numberOfSectionsInTableView" ,
gets called ok (which just returns 1).
The "tableView:numberOfRowsInSection" which returns the number of
Items in a "DetailArray" (initially zero).
The user then clicks a button and a URL is downloaded and Parsed
using a secondary thread. As items are parsed I want to add them to
the table view and have the Table View GUI update. The method I use
add the items to the array is as follows. I had expected that
"tableView:cellForRowAtIndexPath" would have been called to set the
cell for the item, but this doesn't seem to be the case, since I have
a breakpoint in that method and it never seems to get called. The
TableView cell seems to be working ok if I
tableView:numberOfRowsInSection and just set a dummy cell in
"tableView:cellForRowAtIndexPath" it adds the item ok.
Any ideas on what could be wrong?
Thanks in Advance
All the Best
Dave
Here is the method that adds the items to the Table View.
- (void)parser:(ParserBase*)theParser didParseItems:(NSArray*)
theItemDictionaryArray
{
NSEnumerator* myArrayEnumerator;
NSDictionary* myDictionary;
NSString* myObjectNameString;
NSString* myFactYearString;
NSString* myFactMonthString;
NSString* myFactDayString;
NSString* myFactSourceDatabaseString;
NSString* myFactTextString;
static int myObjectCount = 0;
NSArray* myIndexPaths = nil;
[self.mFactDetailArray addObjectsFromArray:theItemDictionaryArray];
myArrayEnumerator = [theItemDictionaryArray objectEnumerator];
while (myDictionary = [myArrayEnumerator nextObject])
{
myIndexPaths = [NSArray arrayWithObjects:[NSIndexPath
indexPathForRow:myObjectCount inSection:0],nil];
[self.mFactTableView insertRowsAtIndexPaths:myIndexPaths
withRowAnimation:YES];
if ((self.mFactTableView.dragging == NO) &&
(self.mFactTableView.tracking == NO) &&
(self.mFactTableView.decelerating == NO))
{
self.title = [NSString stringWithFormat:NSLocalizedString(@"Top %d
Songs", @"Top Songs format"), [mFactDetailArray count]];
[self.mFactTableView reloadData];
}
myObjectNameString = [myDictionary objectForKey:[ParserXML
parserObjectFieldName]];
myFactYearString = [myDictionary objectForKey:kField_FactYear];
myFactMonthString = [myDictionary objectForKey:kField_FactMonth];
myFactDayString = [myDictionary objectForKey:kField_FactDay];
myFactSourceDatabaseString = [myDictionary
objectForKey:kField_FactSourceDatabase];
myFactTextString = [myDictionary objectForKey:kField_FactText];
//********** NSLog(@"********************** item:%d",myObjectCount);
#if 1
NSLog(myObjectNameString);
NSLog(myFactYearString);
NSLog(myFactMonthString);
NSLog(myFactDayString);
NSLog(myFactSourceDatabaseString);
NSLog(myFactTextString);
#endif
[myObjectNameString release];
[myFactYearString release];
[myFactMonthString release];
[myFactDayString release];
[myFactSourceDatabaseString release];
[myFactTextString release];
myObjectCount++;
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden