I’m having trouble inserting an array to the table view. I have an array and i stored it in alDescArray.
Which is alDescArray = ( where its printed in through NSLog. The table doesn’t show anything which part of my code when wrong?
"Block1",
"Block2",
"Block3"
)
- (void)viewDidLoad
{
NSArray *BusRoute = alightDesc;
int i;
int count = [BusRoute count];
for (i = 0; i < count; i++)
{
NSDictionary *dic = [BusRoute objectAtIndex: i];
NSDictionary *STEPS = [dic valueForKey:@"STEPS"];
alDescArray = [STEPS valueForKey:@"AlightDesc"];
}
[super viewDidLoad];
}
and this is the code for tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [alDescArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [alDescArray objectAtIndex:indexPath.row];
return cell;
}
Pls help thanks
Apparently your tableview’s delegate / dataSource is not set.
.h
.m