Beginning Table Views · Challenge: Creating More Rows | Ray Wenderlich


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/7

I think there’s a bit of a mismatch between the instructions for the challenge and the ways they’ve been executed in this video.

The ask is to populate the list with the logic:
indexPath.row % 5 ==0
indexPath.row % 5 ==1
indexPath.row % 5 ==2
indexPath.row % 5 ==3
indexPath.row % 5 ==4

But the example is completed with the logic:
indexPath.row % 5 ==0
indexPath.row % 4 ==0
indexPath.row % 3 ==0
indexPath.row % 2 ==0
indexPath.row % 1 ==0

Both work, but the results will turn out differently if anyone is comparing the results. Might want to switch one to match the other just so beginners aren’t scratching their heads trying to figure out why their results look different. :slight_smile:

Thanks for the heads up. I’ve added an author’s note to correct the issue.

Hello @bdmoakley
sorry but I can’t understand this masmatic way to print this 5 string values to 1000 Cell?
It will be fine to Explain it a bit to me :slight_smile:
also we can use the Array instead this magmatic way?

Hi Hussien, I’m not quite sure I understand what you mean. Would you please clarify? Note, we do use arrays later in the course. This is just to get you started. After all, we walk before we can run. :]

yeah thanks I understood you now

The main issue is actually that the video before this one leaves us with the numberOfRowsInSection method returning 1 and this video starting with asking us to increase it from 5 to 1000.
Having done this in the book as well I recall something similar but maybe there is a bit of confusion between the videos.

Maybe if you update it you could include the upcoming Swift 5 feature of "indexPath.row.isMultiple(of: Int) :slight_smile:

Ah I see - something looks like it was dropped here. I’ll re-review post WWDC 2019. We may reassess the approach of this course. More to come! :slight_smile:

1 Like

Although the slide in the video was incorrect, I went with it and used a switch statement instead:

            // The formatting is indeed terrible
            switch indexPath.row % 5 {
            case 0: label.text = "Take a jog"
            case 1: label.text = "Watch a movie"
            case 2: label.text = "Code an app"
            case 3: label.text = "Walk the dog"
            case 4: label.text = "Study design patterns"
            default: label.text = "Failed to divide."

image

Would it be possible to break up the description into multiple lines?

Edit: The switch statement causes issues later down the road.

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Not with our current system, but I will file a ticket with engineering and see what we can do.

If you are confused about how rows and sections work like me, search " Filling a Table with Data" in apple’s documentation which you should know how to open it. It explains concisely with nice examples about rows, sections and anything you need to know first before using the UITableView.

Also, stanford’s course of UITableView is also very helpful but be warned that is for some one who is very good at coding first.