views:

31

answers:

1

Hi, I am using TouchJSON to retrieve the JSON response from http://enbr.co.cc/TrailsApp/shops.php. In my app I use this code to handle a url scheme.

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    if (!url) {
        return NO;
    }
    NSString *urlString = [url absoluteString];
    NSString *urlStringDecoded = [urlString stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    NSArray *list = [urlStringDecoded componentsSeparatedByString:@"="];
    NSString *urlPrefix = [list objectAtIndex:0];
    NSString *name = [list objectAtIndex:1];
    if ([urlPrefix isEqualToString:@"tridetrails://opentrail?name"]) {
        TrailViewController *trailViewController = [[TrailViewController alloc] initWithNibName:@"TrailViewController" bundle:[NSBundle mainBundle]];
        trailViewController.trailToGoto = name;
        [self.navigationController pushViewController:trailViewController animated:YES];
        [trailViewController release];
    }
    if ([urlPrefix isEqualToString:@"tridetrails://openshop?name"]) {
        ShopViewController *shopViewController = [[ShopViewController alloc] initWithNibName:@"ShopViewController" bundle:[NSBundle mainBundle]];
        shopViewController.shopToGoto = name;
        [self.navigationController pushViewController:shopViewController animated:YES];
        [shopViewController release];
    }
    return YES;
}

How can I push the correct entry from my NSDictionary created from the JSON to the ShopViewController based on the NSString name? Here is my dictionary printed out by NSLog with NSLog(@"%@", myObj);. Thanks in advance.

{
    shops =     (
                {
            blurb = "Bootdoctors blurb";
            image = bootdoctorslogo;
            locations = "Mountain Village";
            motto = "Bootdoctors shop motto";
            name = Bootdoctors;
        },
                {
            blurb = "Easy Rider blurb";
            image = easyriderlogo;
            locations = Telluride;
            motto = "Easy Rider shop motto";
            name = "Easy Rider";
        },
                {
            blurb = "Paragon Ski & Sport blurb";
            image = paragonskiandsportlogo;
            locations = Telluride;
            motto = "Paragon shop motto";
            name = "Paragon Ski & Sport";
        },
                {
            blurb = "Telluride Sports blurb";
            image = telluridesportslogo;
            locations = "Telluride and Mountain Village";
            motto = "Telluride Sports shop motto";
            name = "Telluride Sports";
        }
    );
}