Closed KoonChaoSo closed 8 years ago
You could wrap the block in your hook, but really not something where Aspects can help you much.
Please post questions like this on StackOverflow.
Can Aspect wrap the block in my hook?
Yep.
PLease use StackOverflow for questions. It is very inconsiderate of you to ignore my previous comment.
[self.manager POST:path parameters:mapParams success:^(AFHTTPRequestOperation *operation, id responseObject) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ { NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; NSDictionary *responseDic = [self p_JSONStringToNSDictionary:responseString]; NSInteger statusCode = [self statusCode:responseDic]; if(statusCode == 200) { if (success){ success(operation, responseDic); } } else { NSString *str = [responseDic objectForKey:@"message"]; if (str.length == 0) str = @"error"; NSError *error = [NSError errorWithDomain:str code:statusCode userInfo:nil]; fail(operation, error); } }); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ { NSError *error = [NSError errorWithDomain:@"error" code:100001 userInfo:nil]; fail(operation, error); }); }];
How can i add some log using statusCode to success block with Aspects ?