I have 2 VCs, first is BooksDetailViewController which has the NSString myBookString. Another on is FavBooksViewController which has the favBookList NSMutableArray. I want to pass the NSString myBookString from the 1st VC to include it in the favBookList NSMutableArray which then populates the table.
I have included @class FavBooksViewController; in the BooksDetailViewController.h
Imported #import "FavBooksViewController.h" in the BooksDetailViewController.m
The action in the BooksDetailViewController.m looks like this:
- (IBAction)addToFav:(id)sender {
FavBooksViewController *mdvc;
[mdvc.self.favBookList addObject:myBookString];
}
In FavBooksViewController.h I have
@interface FavBooksViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) id delegate;
@property (nonatomic,strong) NSMutableArray *favBookList;
In the FavBooksViewController.m - #import "FavBooksDetailViewController.h"
In the ViewDidLoad I tried to include this line
self.favBookList = [[NSMutableArray alloc]initWithObjects:nil];
But I have commented it out. With it our without it the UITableView isn't working. And of course I have this:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.favBookList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"favBooksCell"];
cell.textLabel.text = [self.favBookList
objectAtIndex:indexPath.row];
return cell;
}
No matter what, the UITableView is just empty, no cells, nothing. What can be the possible mistake here? What am I doing wrong? Thanks in advance!