iosfreak
iosfreak

Reputation: 5238

reloadData Issues

I am attempting to reload the data from my tableView. When calling it from it's own void, it doesn't work and nothing happens. However, when looking around it works when I delete a cell. I am thinking it has something to do with my INIT. Can you help me solve it? Thanks.

Below is my code!

- (id) init {

//NSLog(@"%@", theUserID);
// Set up database connection
NSString *myDBTwo = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"flashpics.db"];
databaseTwo = [[Sqlite alloc] init];
[databaseTwo open:myDBTwo];

//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];

[listOfItems addObject:@"hi!"];

// Add to array to display in the tableView
NSArray *listOfItemsTwo = [databaseTwo executeQuery:@"SELECT * FROM albums"];   
for (NSDictionary *rowone in listOfItemsTwo) {
    NSString *getName = [rowone valueForKey:@"name"];
    if (getName != NULL) {
        [listOfItems addObject:getName];
        [getName release];
    }
}

//[database release];

return self;
}

Here's my void:

- (void)refreshTableView {
[(UITableView *)self.view reloadData];
//[self.tableView reloadData];
}

Thanks in advance.

Upvotes: 1

Views: 1108

Answers (1)

Rob Napier
Rob Napier

Reputation: 299623

You are over-releasing getName, so I would expect this to crash. But if nothing is happening when -refreshTableView is called, then I would expect that self.view is nil. You should verify the following:

  • refreshTableView is actually called
  • self.view is not nil at the point that it is used
  • tableView:cellForRowAtIndexPath: is called, and returns a properly configured cell when requested

Upvotes: 2

Related Questions