views:

30

answers:

0

I'm writing an iPad split view-based application and I've a NSMutableArray with some objects passed to the main tableView with this code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CellIdentifier";

    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }

    iPadSplitViewAppDelegate *mainDelegate = (iPadSplitViewAppDelegate *)[[UIApplication sharedApplication]delegate];

    cell.textLabel.text = [mainDelegate.products objectAtIndex:indexPath.row];

    return cell;}

"products" is the NSMutableArray and it'll be ever filled with different objects each time I call this method:

-(IBAction)changeObjects
{
    iPadSplitViewAppDelegate *mainDelegate = (iPadSplitViewAppDelegate *)[[UIApplication sharedApplication]delegate];

    [mainDelegate.products removeAllObjects];

    mainDelegate.products = [[NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"newProducts" ofType:@"plist"]] retain];
}

So when I re-filled my NSMutableArray the main tableView give me the same object of the first filling and not the new objects because I've to refresh the table.

[tableView reloadData];

but xcode give me the following errors:

  • error: expected ':' before '.' token

  • confused by earlier errors, bailing out

So how can I refresh the data in my main tableView? And is there a way to re-call the (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath method?

(sorry for my bad english and excuse me for these questions but I'm new in iPad/iPhone programming )