What I am trying to do is load a list of people (JSON format) from a remote server, save the file onto disk, and then parse the result and return an NSArray *
back to the caller.
I have created a EmployeeDirectoryManager
that has the following:
- (NSArray *)loadDirectory:(BOOL)refreshFromServer;
- (void)loadDirectoryFromFile;
- (void)loadDirectoryFromServer;
I would like to use a block on the loadDirectory
method so the caller can be informed when the loadDirectoryFromServer
, which is using an AFJSONRequestOperation
which has a success
block on it.
I need a little direction on how to implement this, or if I am headed down the wrong path.
To use block in your methods as completion handler, firstly you need define new type
typedef void(^TypeComplitionHandler)(id result)
Then you can pass block to your method. For example