0

アドレスを取得するために Google API を呼び出し、ここで API を呼び出します。

-(void)searchviews:(NSString*)EditString selector:(SEL)sel
{  
    NSLog(@"Welcome To Search views");

    searchviews=sel;
     NSString *path =[NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?address=%@&sensor=false",EditString]; 

    NSURL *url=[NSURL URLWithString:path];
    NSLog(@"hiii---%@",url);
    ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:url];
    [request setRequestMethod:@"POST"];
    [request setDelegate:self];
    [request startAsynchronous];
    [drkSignUp showWithMessage:nil];
    NSLog(@" Complet--------------- "); 

Request Method については、 like を呼び出します。

- (void)requestFinished:(ASIHTTPRequest *)request {

    //NSLog(@"%@",[request responseString]);

    NSString *func = [self getFunc:[request url]];

    NSLog(@"%@\n%@",func,[request responseString]);

 if ([func isEqual:@"json?address=%@&sensor=false"]) 
            {
                NSDictionary *resDict = [parser objectWithString:[request responseString] error:nil];
                NSLog(@"---- ResData%@",resDict);
                NSString *result = [resDict objectForKey:@"successful"];
                NSLog(@"hiiiii google api calling............");

                [drkSignUp hide];
                [self.delegate performSelector:searchviews withObject:[resDict objectForKey:@"results"]]; 

はそんな感じですが、問題作成は楽しいです。私が電話するとき

if ([func isEqual:@"json?address=%@&sensor=false"])

cos を呼び出すのではなく、Dynamic String.So で %@ の代わりに func に何を配置する必要がありますか?

4

1 に答える 1

0

ASIFormDataRequest次のようなuserInfo 辞書を埋めることができます

//After this line
ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:url];
//Add 
request.userInfo = [NSDictionary dictionaryWithObject:@"EditString" forKey:@"request"];

次に

- (void)requestFinished:(ASIHTTPRequest *)request {
    //Get the request userInfo
    NSString *str = [request.userInfo objectForKey:@"request"];
    //now fill the request string
    NSString *requestString = [NSString stringWithFormat:@"json?address=%@&sensor=false", str];
    //Check it with func
    if ([func isEqual:requestString]) 
    {
        //Continue your procedure
    }
}
于 2012-06-18T05:56:52.817 に答える