I am new to xcode, and I try to play with UITableView to show content in array.
I try to put some array inside Feed, and try to show them in table.
but the error is hinted at this instances
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
on cell.textLabel.text = self.imageTitleArray[indexPath.row];
it says expected method to read array element not found on object of type NSArray
I am confused, why it wont read the array, captain obvious please help
this is my H files
#import <UIKit/UIKit.h>
@interface FeedTableViewController : UITableViewController
@property (strong, nonatomic) NSArray *imageTitleArray;
@end
and this is my M files
#import "FeedTableViewController.h"
@interface FeedTableViewController ()
@end
@implementation FeedTableViewController
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Feed";
self.imageTitleArray = @[@"Image 1",@"Image 2",@"Image 3", @"Image 4",@"Image 5"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.imageTitleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if(cell==nil){
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = self.imageTitleArray[indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end