mercredi 25 mars 2015

Populating table with 2 arrays

Hello, I'm trying to populate a tableview controller with objects from 2 different arrays but it crashes and gives this error "Terminating app due to uncaught exception 'NSRangeException', reason: ' -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]" how do i fix this? below is my code:***



(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
}

(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.
return (self.BookrefArray.count + self.journalrefArray.count);
}

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cells";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Journal *myjournal =[self.journalrefArray objectAtIndex:indexPath.row];
[cell.detailTextLabel setText:[myjournal valueForKey:@"journalname"]];
[cell.textLabel setText:[NSString stringWithFormat:@"%@, %@",[myjournal valueForKey:@"surname"],[myjournal valueForKey:@"firstname"]]];
Book *mybook =[self.BookrefArray objectAtIndex:indexPath.row];
// Configure the cell...
[cell.detailTextLabel setText:[mybook valueForKey:@"bookTitle"]];
[cell.textLabel setText:[NSString stringWithFormat:@"%@, %@",[mybook valueForKey:@"authorSurname"],[mybook valueForKey:@"authorOthernames"]]];

return cell;}`-



Aucun commentaire:

Enregistrer un commentaire