I'm using custom UITableview cell to display the distance between my current location and few random places in the world. If my current location is Newyork city, then the distance between my current location and India is somewhere around 4000 miles & the distance between my current location to London would be 2000 miles etc. Now I want to use an slider in my table view, to define a place within the specified range. For instance, if I set the minimum value of my slider to 0 miles and maximul value as 50 miles, I want to display only those places within that range (here it is 50 miles) in my Tableview. If I increase or decrease the slider range, the values in my tableview should also be changed. I'm using CLLocation to find the distance between two points.
Ideas are appreciated.
Each time when your location changed you should calculate and store the distance in corresponding location data with key as distance. Now at the delegate method called with value change of your slider, filter the array with
Here allLocations is an array having all locations and filteredLocations is array that is stores the filtered location and show them in tableView.
If you do not want to store the distance then at your slider value changed delegate use
which will filter the values according to current location of user. Here allPlaces is array with all locations, myLocation is user's current location and filteredPlaces is array within limit. Choose whatever you want.