I have a singleton class which only serves as web service calls for my application. Suppose that class is named as MySingleTonClass
. Now to get various data i call different methods of the class.
eg. [[MySingleTonClass sharedInstance] getDataFromServer];
Now my question is that, there are certain times when i got to make nested web service calls (calling API on completion of another API call). And i am using this only class to do all the API calls, and as this is a singleton, will it work? OR even i am calling this class's method on subsequent lines.
line 1 - [[MySingleTonClass sharedInstance] getDataFromServer];
line 2 - [[MySingleTonClass sharedInstance] getOtherDataFromServer];
Will this work too? From my understanding, an instance of a singleton will remain in memory only once. That is once instance of it at a time. Therefore if invoking sharedInstance while already a work is being done by the sharedInstance, (already in memory) work as planned? or should i change the WebServiceCall class to a normal class and create object everytime, as that would make the class have multiple objects at a time therefore making multiple API calls at the same time.
Please suggest.thanks in advance.
EDIT
The singleton class has AFNetworking methods implemented inside of them