1

Web サービスを呼び出して、サーバーに書き起こし音声ファイルをアップロードする方法を使用しています。方法は次のとおりです。

    - (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;

}

このメソッドは、まだ応答として NSstring を返しています。私が望むのは、このメソッドが NSDictionary を返してくれることです。その辞書内のキーの値を別の場所で使用する必要があるためです。誰かがこれについて私を助けることができますか?

4

2 に答える 2

1

こんにちは shikher maddy は、正しい nu は次のように文字列を解析できると言っています

if (responseString == NULL) {
    // do something u want
} else {
    NSDictionary *jsonResponse = [responseString JSONValue];
    NSLog(@"  %@",jsonResponse);
}
于 2013-05-24T14:50:55.510 に答える
1

私があなたなら、次のようにSBJSONParserを使用します。

SBJsonParser *parser=  [[SBJsonParser alloc] init];

NSDictionary *dictionnary = [parser objectWithString:responseString error:nil];
于 2013-05-24T14:58:08.920 に答える