0

I have problem with TableView its empty.

In (.h) file:

@interface TableViewController : UITableViewController{

NSMutableArray *coursArray; }   

In (.m) file:

In viewDidLoad

[coursArray addObject:[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"AR111",@"courseCode",@"Arabic Communication Skills (I)",@"courseName", nil]];
[coursArray addObject:[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"AR112",@"courseCode",@"Arabic Communication Skills (II)",@"courseName", nil]];

and in numberOfRowsInSection

return [coursArray count];

and in cellForRowAtIndexPath

cell.textLabel.text = [[coursArray objectAtIndex:indexPath.row]objectForKey:@"courseCode"];

So whats wrong please help me :)

7
  • 1
    are you sure that you set the delegate and the dataSource of the table correctly? Commented Jun 16, 2012 at 17:07
  • Omar makes a great suggestion. You could put NSLog or debugger breakpoints at numberOfRowsInSection and cellForRowAtIndexPath and make sure they're being invoked like you think they should. Commented Jun 16, 2012 at 17:11
  • And, of course, I assume you're doing the necessary alloc and init of coursArray itself (e.g. coursArray = [[NSMutableArray alloc] init]), too, in viewDidLoad, too, because you're not showing that here. Commented Jun 16, 2012 at 17:13
  • Yes, if I use cell.textLabel.text = @"Yes"; with numberOfRowsInSection return 2; its work. Commented Jun 16, 2012 at 17:13
  • thanks its work now I forgot coursArray = [[NSMutableArray alloc] init] Commented Jun 16, 2012 at 17:19

1 Answer 1

2

Very good. Just make sure to do the necessary alloc and init of coursArray itself in viewDidLoad, too, e.g.

coursArray = [[NSMutableArray alloc] init]
Sign up to request clarification or add additional context in comments.

Comments

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.