Home > DeveloperSection > Forums > dispalying data from NSarray to table view
Nigel Bunyan
Nigel Bunyan

Total Post:20

Posted on    August-12-2015 12:01 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 754  View(s)
Rate this:

I am new in iOS and making a lightweight application. I am taking two textfield entries from one view controller and storing them in NSDictionary. I am transferring those data in NSArray. Now I want to display those data from NSArray to table view. I am using this line of code:

cell.textLabel.text = [self.myArray objectAtIndex:indexPath.row];

But my app is crashing when cursor comes at this line. Help is appreciated. Thanks in advance.


Tarun Kumar

Total Post:214

Posted on    August-12-2015 10:51 PM

For UITableView you have to define at least 2 methods:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:

(NSIndexPath *)indexPath

It seems your method numberOfRowsInSection is not implemented.

Try to add this:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: {

    return [self.myArray count];


Of course your ViewController have to be delegated for UITableViewDataSource and UItableViewDelegate.

Modified On Aug-12-2015 10:52:19 PM

Don't want to miss updates? Please click the below button!

Follow MindStick