I am new to iOS objective C and currently am enhancing some features to an existing project. I would like to implement a callback method to return the results from an API call in the viewDidLoad method as I need the results to determine the number of icons to display on the screen.
I have looked around for various answers, however, I am not sure what has went wrong and I am unable to return the responses from the APIs to the NSMutableArray in the ViewDidLoad method. I would greatly appreciate any help on how to go about get the response into the customerArray in the viewDidLoad method
This is the Service Delegate header file that defines the method:
I made use of the first method requestCompleted
in my ViewController file to retrieve the response returned from the API. Within this method, customerArray
which is a globally declared array contains the items that was returned from the API, however when this array was called in the viewDidLoad
method, it appears to be null.
I tried the following way to retrieve using the dispatch async method, but the customer Array is still empty