0

私はこのURLを持っていますNSURL *url = [NSURL URLWithString:@"http://site.com/ArcGIS/rest/services/POI_Data/MapServer/0/query?&where=ToegangsNr+%3D+5002&returnGeometry=true&outSR=4326&f=json"];

しかし、文字列の 5002 値を NSUserdefault で変更したいと考えています_phonenumber

これどうやってするの?

この関数の他のコードは次のとおりです。

ASIHTTPRequest *_request = [ASIHTTPRequest requestWithURL:url];
__weak ASIHTTPRequest *request = _request;

request.requestMethod = @"POST";
[request addRequestHeader:@"Content-Type" value:@"application/json"];
[request appendPostData:[json dataUsingEncoding:NSUTF8StringEncoding]];
// 5
[request setDelegate:self];
[request setCompletionBlock:^{
    [MBProgressHUD hideHUDForView:self.view animated:YES];

    NSString *responseString = [request responseString];
    NSLog(@"Response: %@", responseString);
    [self plotCrimePositions:request.responseData];

}];
[request setFailedBlock:^{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    NSError *error = [request error];
    NSLog(@"Error: %@", error.localizedDescription);
}];
4

2 に答える 2

1
    NSURL *url = [NSURL URLWithString:@"http://site.com/ArcGIS/rest/services/POI_Data/MapServer/0/query?&where=ToegangsNr+%3D+5002&returnGeometry=true&outSR=4326&f=json"];
NSString *urlString = [url absoluteString];
urlString = [urlString stringByReplacingOccurrencesOfString:@"5002" withString:[userDefaults objectForKey:@"_phoneNumber"]];
NSLog(@"%@",urlString);
url = [NSURL URLWithString:urlString];
NSLog(@"%@",url);

それが役立つことを願っています。

于 2012-11-14T13:21:07.057 に答える
1

これを試して:

NSString *urlStr = [NSString stringWithFormat:@"http://site.com/ArcGIS/rest/services/POI_Data/MapServer/0/query?&where=ToegangsNr+%%3D+%@&returnGeometry=true&outSR=4326&f=json", [[NSUserDefaults standardUserDefaults] objectForKey:@"_phonenumber"]];
NSURL* url = [NSURL URLWithString:urlStr];
于 2012-11-14T13:31:05.987 に答える