[swift-users] Issues with UITableView*

Adam Stoller ghoti1 at gmail.com
Mon Sep 12 16:42:50 CDT 2016


I’m trying to do something that I thought would be rather simple: 
Display a list of information in rows of a table (in this case, each row would contain a ‘name’ and a ‘location’ label)
If clicked on once, the row should become selected (highlighted and checked)
If clicked on again (same row), the row should become un-selected (un-highlighted and un-checked)
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.



—fish
(Adam Stoller)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debugging_log.pdf
Type: application/pdf
Size: 73426 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExistingLocationTableViewCell.swift
Type: application/octet-stream
Size: 1181 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExistingLocationsViewController.swift
Type: application/octet-stream
Size: 5278 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LocationObject.swift
Type: application/octet-stream
Size: 566 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0002.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160912/d2141006/attachment-0004.html>


More information about the swift-users mailing list