I am working on project in which data come from server.
Data contain(Latitude,Longitude,District and Street Name). I saved each field in separate array and just display district and street name related to that location on tableview.
When user click on specific row of table-view another screen appears and location of that specific index of tableviewcell shows on map viva specific lat,lon.
When I implement search bar on tableview to search district name then how can I get exact longitude and latitude for searched district?
You can get index of district from district array and get longitude from longitude array at same index.
Swift:
let index = find(district,districtArray)!
let longitude = longitudeArray[index]
let latitude = latitudeArray[index]
Objective-C:
int index = [districtArray indexOfObject:district];
double latitude = latitudeArray[index];
double longitude = longitudeArray[index];
I assume that in all arrays data exists, but if there's a chance that some array at some index will be empty do error checking as well.