DEV Community

Discussion on: Help needed ;-;

Collapse
 
recursivefaults profile image
Ryan Latta

Okey dokey, its been a while here.

There're two things I need to point out.

  1. Your specific problem is because Item isn't initialized to anything. You're trying to access something that isn't there.

  2. You're building a UITableView which is something every iOS developer has to figure out and it takes a little bit before it makes sense. So here we go.

In your UITableViewDelegate and DataSource you have methods to create your UITableViewCell, I forget their name. Its got a line like... initializeTableCellWithIdentifier. In that same method you have to give the TableViewCell all the information it needs. Don't have your TableViewCell connect back to your controller. Pass the Item from your controller INTO the tableview cell

So in your DataSource/Delegate method you might do something like, cell.setItem(item).

The reason you need to have it work this way is that those TableViewCells get recycled. Most people don't realize this. But iOS only uses a few TableCells and when one scrolls off screen it gets marked for re-use. So you have to reset those cells in that method EVERY time. There's also another method you can use to optimize this like.. willAppear or something, but don't worry about that for now.

I believe in the documentation Apple provides they have a demo project for this that will be really helpful in getting this set up and showing you how to manipulate a UITableViewCell.

Collapse
 
lilkiwi profile image
Kiwi

Aaaaaa thank you a lot 💕💞💕💕 , I accessed the cell informations but how do I initialize? 🥲🥲 what is the code + I got a lot of questions srry for bother