I'm quite new to iOS Development and wanna get stuck right in :) I'm just looking to find the best practice for this:<p>I know I can use CLLocationManager to get the users location but I want to create an app that does this:<p>User logs in > app checks web server for online users in specified radius in miles/feet of the current users phone > displays users.<p>What is the best way to go around this? much appreciated for all your help.
I think stackoverflow is better for this specific question.<p>Having said that most databases (on the backend) have spatial extension where you can run queries like 'where inside(point,geometry)'. So you create a bounding box or circle around the user, then run a query. That's faster than calculating distances between all users. The databases have special indices for geographic lookup.
Both point and geometry probably need to be specified in WKT format.
<a href="http://www.gaia-gis.it/spatialite-2.1/SpatiaLite-manual.html" rel="nofollow">http://www.gaia-gis.it/spatialite-2.1/SpatiaLite-manual.html</a>
<a href="http://docs.mongodb.org/manual/applications/geospatial-indexes/" rel="nofollow">http://docs.mongodb.org/manual/applications/geospatial-index...</a>
Assuming you have the coordinates for the each online user, iterate that collection, create a CLLocation object from the coordinate data, and check that object against CLLocation method distanceFromLocation with a radius value.<p><a href="https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/index.html#//apple_ref/occ/instm/CLLocation/distanceFromLocation" rel="nofollow">https://developer.apple.com/library/ios/documentation/CoreLo...</a>: