I have an iPhone application that reads the details of local businesses from a .csv file. There are 3 main section:
- Where to Sleep
- Where to Eat
- What to Do
Depending on which one is clicked (e.g. Where to Sleep), you get a sub section of options like:
- B&B
- Hotels
- Caravan and Camping
Then if you select e.g. Hotels, you are shown a UITableView of the list of hotels. The UITableView has 2 sections in it to differentiate between 3 Star and 4 Star hotels. See screen grab below.
This is all OK so far but when I click on a cell to segue to the business' details page (a UIViewController), I segue with the wrong cell information.
I have stepped throughout the code in my UITableViewController's didSelectRowAtIndexPath and it would seem that I am registering the correct selection on each cell.
As an example, in the image above, if I select Ballyroe Heights Hotel, this is the output I get when stepping through it. Where dataArray() is an NSMutableArray that holds an NSMutableArray of 3 Star and an NSMutableArray of 4 Star Hotels that are added as below.
[dataArray addObject:threeStarArray];
[dataArray addObject:fourStarArray];
However, clicking on Ballyroe Heights Hotel displays the details for Ballygarry House Hotel and Spa
A clue to what may be going on is in the Shopping section. Below is a screen grab of what the Shopping view and sections look like.
Clicking on Manor West Retail Park display the correct information. But clicking on Shaws Department Store displays Manor West Retail Park again. Then clicking on Thats Perfect displays Shaws Department Store - and clicking on Sean Hussey displays Thats Perfect details. This is repeated for each section.
Clicking on Hardware (Kellihers...) stars the display again at Manor West Retail Park.
But again stepping through it, it seems that the correct cell is chosen in didSelectRowAtIndexPath().
In the example below I have selected Sean Hussey and again the output shows that the correct cell was chosen and that the segue sender:selectedCell is the Sean Hussey object.
However, the object that is passed to the UIViewController is of Thats Perfect.
Can anyone see where I am going wrong? Additional code can be supplied but Im sure the issue has to lie here as this method checks for row selections and performs the segues.