Error updating UITableView after smaller sized JSON response?

David

Currently, I have my app hitting my endpoints, and getting back 10 or less items. In the event the items returned is less than 10, and the UITableView is already showing 10 items, reloadData() will cause an error because the size is not the same as it was last time. Right now, when I get my response all I do is:

tableView.beginUpdates()
self.items = items //where self.items is the array that backs the UITableView, and items are the items I got back in form of JSON from the server.
tableView.reloadData()
tableView.endUpdates()
Hassan Rafique Awan

Why will it cause error? If you are using tableView.reloadData(), you don't need to call endUpdates() and beginUpdates(). Just simply assign the items and reload tableView data.

self.items = items tableView.reloadData()

If you are on the background thread call the above code on the main queue.

dispatch_async(dispatch_get_main_queue()) { () -> Void in
            // Code runs on main queue!
        }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to do dynamic sized json response parsing?

From Dev

Json parsing error after getting Response

From Dev

Updating JSON response using Javascript

From Dev

error after updating sdk

From Dev

UITableView cellForRowAtIndexPath function not updating after reload function

From Dev

Updating data in UITableView after asynchronous load

From Dev

How to fix symfony 1.4 error "Empty response header name, aborting request" after updating to php 7

From Dev

Updating UITableView when retrieving json data

From Dev

UITableView+YouTubeAPI parsing JSON response for statistics

From Dev

SwiftyJSON: Update Cells in UITableView from JSON response

From Dev

UITableView not updating

From Dev

Error after updating to Xcode 7

From Dev

Error after updating npm, cordova

From Dev

Getting this error after updating Meteor

From Dev

error after updating the Xcode to 7.0

From Dev

error after updating the support library

From Dev

Getting error after updating swift?

From Dev

routing error after updating emberjs

From Dev

Broken package error after updating

From Dev

PHPMyAdmin error after updating EasyPHP

From Dev

php eval() error after updating

From Dev

Error after updating buildToolsVersion to '26.0.2'

From Dev

UITableView get smaller

From Dev

ParseUser JSON response error

From Dev

Swifty JSON UITableView background error

From Dev

HTTP response after error handling

From Dev

fatal error after reloadData UITableView in other class

From Dev

UIStackView not updating after updating height of subview (UITableView with no scroll) while inside a ScrollView

From Dev

Updating custom component's form after getting a response

Related Related

HotTag

Archive