0

我目前正在从谷歌提取方向并将它们存储到一个数组中。然后我有一个整数来表示找到的方向数量,并让 forloop 通过 NSLog 正确显示它们(包括 html)

我的问题是,如何将其转换为 UIWebView 以便在列表中正确显示此信息?

到目前为止,这是我的代码:

NSError *error;
NSString *currentLoc = @"Hyannis, MA";
NSString *directionsString = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@, %@, %@&sensor=false", currentLoc, [self.selectedEvent objectForKey:@"eventAddress"], [self.selectedEvent objectForKey:@"eventCity"], [self.selectedEvent objectForKey:@"eventState"]];

directionsString = [directionsString stringByReplacingOccurrencesOfString:@" " withString:@"+"];

NSData *jsonResponse = [NSData dataWithContentsOfURL:[NSURL URLWithString:directionsString]];

NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:&error];

self.directionsArray = [[[[jsonDict valueForKey:@"routes"] valueForKey:@"legs"] valueForKey:@"steps"] valueForKey:@"html_instructions"];

NSUInteger total = [self.directionsArray count];

for (int i = 0; i < total; i++)
{
    NSString *statusString = [jsonDict valueForKey:@"status"];
    NSLog(@"JSON Response Status:%@", statusString);

    NSLog(@"Direction: %@", [self.directionsArray objectAtIndex:i]);

}
4

0 回答 0