Hesham Saeed
Hesham Saeed

Reputation: 5378

Table and Array

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 :)

Upvotes: 0

Views: 53

Answers (1)

Rob
Rob

Reputation: 437402

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

coursArray = [[NSMutableArray alloc] init]

Upvotes: 2

Related Questions