ios - Refresh view controller with new data after JSON request -


nsstring * storyboardname = @"storyboardx"; uistoryboard *storyboard = [uistoryboard storyboardwithname:storyboardname bundle: nil]; uiviewcontroller *vc = [storyboard instantiateviewcontrollerwithidentifier:@"viewcontrollerx"]; [vc.view setneedsdisplay]; 

i trying refresh display in view controller after json request completes in thread. data refreshes correctly, view not. trying setneedsdisplay @ end of data pull method crashes nsrangeexception index 0 beyond bounds. assume because view controller above not instantiated correctly, or current view not being deallocated. arc on.

i have tried [vc.view viewdidload] same result.

the code above located @ end of (void)main json pull method.

1) json pull not executing in main thread (i'm assuming you've not shown it, , if not should anyway if json being obtained server) , gui code can't called on background thread.

2) should not doing attempting anyway, unless want load view controller opposed refresh existing 1 loaded. - code have create brand new instance of view controller, if have 1 showing have 2 duplicate instances of same view controller.

you should add method view controller redraw contents. when json ready fire nsnotification. have view controller listening notification , call method doing refreshing of views.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -