I have a code where it shows all countries and we can select a specific country from it. What i want now is when i select a country i want to see the list of states in that country. Can any one please help me in that ? Is there a method or API for it? Any help is appreciated. thanks
2 Answers
Use db
for getting countries and its states
. Just download it.
Now use this db to query like this:
NSString *queryString = [NSString stringWithFormat:@"select zone_id , name from
zone where country_id = %d", countryID]; //here countryID is country code
EDIT : Get all countries with query like this:
NSString *queryStrAllCountries = [NSString stringWithFormat:@"select name from
countries"];
Get countryID from country selected with query like this:
NSString *queryStrCountry = [NSString stringWithFormat:@"select country_id from
countries where name='%@'", countryName]; //provide country name selected
Refer this answer which provide information as the same.

- 1
- 1

- 38,095
- 11
- 81
- 132
-
but it shows countryID not declared. – Kiron Nov 06 '12 at 11:10
-
here countryID is number defined in apple standard. See DB – Paresh Navadiya Nov 06 '12 at 11:17
It depends on how you implemented your solution. I assume you are using an UITableView
.
Then the best way to do that would be to set a UINavigationController
as your rootViewController
(in Interface Builders main nib) and use the UITableViewController
view as the root view of the UINavigationController
. Then push another UITableViewController
when a row of the first table is tabbed.
If you already have some information about UINavigationController this lines may help you:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}
If you are looking for a tutorial on UINavigationBar and UITableView have a look here. If you want to search for a tutorial yourself, search for UITableView detail view
.

- 11,765
- 7
- 42
- 85