I'm building an iOS app and i'm using AFNetworking library to POST data to the server.
I have created a function to post data and calling this function in different classes in my app.
I am getting response of the request in the variable called "responseObject" , And i want to return this in the return statement i am not able to identify the return type of responseObject and hence of the function,I tried using NSDictionary but getting following warning:
Conflicting return type in implementation of 'postData:parameters:': 'void' vs 'NSDictionary *'
here is my code:
-(void)postData:(NSString*)postUrl parameters:(NSDictionary *)params{
NSURL *baseURL = [NSURL URLWithString:@"http://xyz:2424/api/"];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
manager.requestSerializer = [AFJSONRequestSerializer serializer]; manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:postUrl parameters:params success:^(NSURLSessionDataTask *task, id responseObject)
{
NSLog(@"response %@",responseObject);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"\n============== ERROR ====\n%@",error);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error adding book" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alertView show];
}];
}