Beginning Table Views · Challenge: Give a Random Description | Ray Wenderlich


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

Why didn’t we put the randomText method in the checklistItem class? I’m unsure when to add a method to a certain class, since for me this method could fit for both objects. Or would it make a huge difference?
Thanks!

Yes, ultimately that’s a design choice. It could make sense in both classes. Since it is directly related to the checklist class, it might make better sense for the checklist item to have the method. But ultimately, it won’t make that big of a difference. I hope that helps!

What about using .randomElement on the array list?

Great idea! I didn’t know about that method. Although I’m glad to show people some of the latest Swift 4 features. A lot of devs still use arc4random to generate random numbers.

I don’t really get how the configureCheckmark method works. With the End version of your source code, when you try to uncheck the checked item, the method is executed with the checked item as item argument, and since it has checked = true property, cell.accessoryType = .checkmark will be executed. So basically it seems for me that the method checks already checked item although it toggleChecks afterwards. But somehow on the simulator it works well. What point of my logic is wrong?

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