Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

OriginalJef

macrumors newbie
Original poster
Mar 1, 2013
3
0
Hye,

I'm searching for a way to see the closed shop, calculated on your current location. I'm a noob in programming for iOS and can't find a way to do it.
The thing is that I have a table view controller with al the shops and I want to press the button it needs to filter the list and give only the nearest shop in the list.

Sorry for the bad english.

Pleas help,
Original jef
 
The short answer is measure the distance to all of them, and disqualify all but the closest.
What have you tried? What code have you written so far?
And how much have you searched this forum?
The spoon fed solution is right here!
 
Hye,

I'm searching for a way to see the closed shop, calculated on your current location. I'm a noob in programming for iOS and can't find a way to do it.
The thing is that I have a table view controller with al the shops and I want to press the button it needs to filter the list and give only the nearest shop in the list.

Sorry for the bad english.

Pleas help,
Original jef

Create CLLocation objects for all your locations.

Then get the current location, and create a CLLocation object for that too.

Then use the CLLocation method distanceFromLocation to calculate the distance from the user's current location to each "shop" in your list of locations. Select the "shop" locations that are within your distance cutoff.

When the user moves a significant distance from his current location (say 1/2 kilometer) you'll need to recalculate your distances.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.