CKRecord and UITableView

I am filtering records from cloudkit based on the user's location. When he moves, CKRecord gets updated and so does UITableView. So far all perfect.

The issue is when the user moves to an area where there are no records and the CKRecord returns nil. When this happens, instead of UITableView displaying nothing, it actually shows the last records that were available before nil.

I would like the table to show something like "No records" or at least nothing at all.

Any ideas?

Accepted Reply

The table's dataSource is responsible for the table's data, so you could call the same code whether or not the CKRecord is nil, and when it's nil purge any existing data you had for the table, then refresh the table.

Alternatively, that same code could hide/show the table and show/hide an alternate view (with a label that says "No records", for instance) when you have no records.

  • The second option worked, thanks

Add a Comment

Replies

The table's dataSource is responsible for the table's data, so you could call the same code whether or not the CKRecord is nil, and when it's nil purge any existing data you had for the table, then refresh the table.

Alternatively, that same code could hide/show the table and show/hide an alternate view (with a label that says "No records", for instance) when you have no records.

  • The second option worked, thanks

Add a Comment