iosjsonasiformdatarequest

Returning NSString instead of NSDictionary


I am using a method to call the Web Services and Upload the Transcription Audio File On the Server. The method is as follows:

    - (NSDictionary *)UploadTranscriptionAudio:(NSString *)uploadfor forPN_ID:(NSString 
   *)pn_id forTaskFlag:(NSString *)taskflag documentPath:(NSString *)documentpath 
    forUserName:(NSString *)username file_path_msd:(NSString *)file_path_msd 
   audioFilePath:(NSString *)audiofilepath{

NSDictionary *response = nil;


NSURL * url = [NSURL URLWithString:[AppDelegate sharedInstance].str_webServiceUrl];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

[request setPostValue:uploadfor forKey:@"Uploadfor"];
[request setPostValue:pn_id forKey:@"PNID"];
[request setPostValue:taskflag forKey:@"task_flag"];
[request setPostValue:documentpath forKey:@"Path"];
[request setPostValue:username forKey:@"Username"];
[request setPostValue:file_path_msd forKey:@"file_path_msd"];
[request setFile:audiofilepath forKey:@"uploadedfile"];

[request startSynchronous];

NSError *error = [request error];
if (!error) {
    response = (NSDictionary*)[request responseString];
    NSLog(@"Response = %@",response);
    return response;
}
return response;

}

This method is still returning me a NSstring in response. What i want is that this method should return me a NSDictionary. As I have to use the value for the keys inside that dictionary somewhere else. Can somebody help me on this.


Solution

  • hello shikher maddy says right n u can parse string as follow

    if (responseString == NULL) {
        // do something u want
    } else {
        NSDictionary *jsonResponse = [responseString JSONValue];
        NSLog(@"  %@",jsonResponse);
    }