ios - Does reloadData of Tableview execute immediately in this case -
i read [_tableview reloaddata] sends message main queue update , display data in table view. based on discuss following case. suppose method sends message main queue before [_tableview reloaddata] in case second message processed before [_tableview reloaddata] ?
now case
suppose have 2 threads ta , tb , have 2 methods methodaand methodb this
this methoda
- (void) methoda { dispatch_async(dispatch_get_main_queue(), ^{ [myarray addobject:@"someobject"]; ///----------<timeframea>---------------- [_tableview reloaddata] }); } this methodb
- (void) methodb { dispatch_async(dispatch_get_main_queue(), ^{ //runs under assumption "someobject" has been displayed in tableview //make changes tableview/ }); } suppose methodb called threadb , occurs during timeframea. in case methodb called before [_tableview reloaddata] ? there way me make sure methodb runs when tableview displaying updated data ?
the main dispatch queue (which associated main thread) serial queue, not concurrent. therefore cannot happen in
dispatch_async(dispatch_get_main_queue(), ^{ [myarray addobject:@"someobject"]; ///----------<timeframea>---------------- [_tableview reloaddata] }); } any other code executes on main queue between adding object , reloading table view.
any other block dispatched main queue executes either before or after block.
Comments
Post a Comment