0

Right now I have a tableview, and I can assure you that the delegate method all work. But I am trying to load the tableview from an array. the same array returns actual objects when i log then earlier in the app, but when I try to access the same array in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath it always returns nil/null.Here is the implementation of - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath:

NSLog(@"cell for row at twitter called");
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

NSDictionary *tweet = [timeLineData objectAtIndex:indexPath.row];
// NSLog(@"Tweet at index %d is %@", [indexPath row], tweet);
//NSLog(@"Tweet: %@", tweet);
cell.textLabel.text = [tweet objectForKey:@"text"];

cell.detailTextLabel.text = [tweet valueForKeyPath:@"user.name"];


return cell;

I am so confused as to why this is, because in all of my other projects the same code works just fine. Any help would be greatly appreciated.

Thanks, Virindh Borra

2
  • When you load the tableview, is your NSLog statement called? What is the code inside your numberOfRowsInSection method? Commented May 18, 2012 at 22:54
  • Its indeed called, and in numberofrowrsinsection it returns 25. Commented May 18, 2012 at 23:48

1 Answer 1

1

Would it help if you access the array using:

[yourArray objectAtIndex:indexpath.row];
Sign up to request clarification or add additional context in comments.

3 Comments

thats what I am doing but it returns nil.
can you post the implementation of the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method? It would help us give you a better answer.
Sorry, there is nothing i can find wrong with the code you posted (the problem may lie elsewhere). The only advice i have with the information given is that the table view cells might be initialized before timeLineData is initialized.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.