Your JSONParser
is asynchronous because of the network connection (it is asynchronous). So, when you currently call parser.jsonDictionary
you see that the data isn't ready yet.
You don't want to try blocking until the data is available, rather you should setup a callback to get the data to your view controller when it's ready (so you can save it and update the UI).
That could be done by adding a delegate
property to your JSONParser
and having the view controller assign itself and implement some callback method. Or, using less code, the JSONParser
can offer a block property that the view controller sets and which is called in connectionDidFinishLoading:
(make sure the @property
uses (copy, nonatomic)`).