I’m trying to do something that I thought would be rather simple: 
  1. Display a list of information in rows of a table (in this case, each row would contain a ‘name’ and a ‘location’ label)
  2. If clicked on once, the row should become selected (highlighted and checked)
  3. If clicked on again (same row), the row should become un-selected (un-highlighted and un-checked)
  4. Alternatively, after clicking and selecting one row, if you click on a different row, the first row should become un-selected and the second row should become selected (i.e.: single-selection list)

For my purposes I created two custom classes:
  • class ExistingLocationsViewController: UITableViewController
  • class ExistingLocationTableViewCell: UITableViewCell

I’ve gone through numerous trial-and-error situations based on some combination of:
  • What I’ve read in books
  • What I’ve read online in various forums
  • What I’ve thought made sense intuitively
  • What I could glean from lots of debugging print statements

The current version of my code seems to satisfy points #1-3, but crashes when attempting to deal with #4 - and I’m not sure that what I’ve done is “good” or “correct” in terms of satisfying the first three points.

I’ve attached the code and the (annotated) debugging log output - the latter gets to a point where I seem to solve #4, but then causes other complications

I’m looking for pointers, advice, suggestions, corrections, etc.  While I’m not looking to have someone write my code for me, I’m certainly willing to accept such a contribution.  Ideally, when done with this, I hope to have a reasonably clear understanding of what was wrong and what is right.

This is only the bare beginnings of the application I’m trying to write, and it’s rather frustrating to run into such a confusing issue on something that - to me - seems like it should be so simple to implement.

Attachment: debugging_log.pdf
Description: Adobe PDF document

Attachment: ExistingLocationTableViewCell.swift
Description: Binary data

Attachment: ExistingLocationsViewController.swift
Description: Binary data

Attachment: LocationObject.swift
Description: Binary data



—fish
(Adam Stoller)

_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to