I need to encapsulate the response from AFNetworking calls in my own method when I write the library. This code closed me:
MyDevice *devices = [[MyDevice alloc] init]; [devices getDevices:@"devices.json?user_id=10" success:^(AFHTTPRequestOperation *operation, id responseObject) { ... can process json object here ... } - (void)getDevices:(NSString *)netPath success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure { [[MyApiClient sharedDeviceServiceInstance] getPath:[NSString stringWithFormat:@"%@", netPath] parameters:nil success:success failure:failure]; }
However, I need to process the json object data returned from getPath before returning to getDevices (). I tried this:
- (void)getDevices:(NSString *)netPath success:(void (^)(id myResults))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure { [[MyApiClient sharedDeviceServiceInstance] getPath:[NSString stringWithFormat:@"%@", netPath] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { ... can process json object here ... } failure:^(AFHTTPRequestOperation *operation, NSError *error) { ... process errors here ... }]; }
But now there is no return to getDevices (). So, how can I process the json object in getDevices and return the block after completion? Please rate the help as I am new to blocks.
Dan
source share