将数组传递给UIWebView

时间:2013-11-13 20:06:38

标签: ios iphone objective-c uiwebview

我目前正在从谷歌提取指令并将其存储到数组中。然后我有一个整数用于找到的方向数量,并让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]);

}

0 个答案:

没有答案