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.
Yes. When the user opens the app I will get their current location and add it to a column in the database 'currentLocation' Then I will query the database like so: select * from users where userOnlineStatus = 'online' and currentLocation = ""; <- That is what I would want to do. Its just calculating the distance so that not all random users are showing up.
Also as @mtmail mentions, the better path for this is probably not on the device itself. It would get expensive where N number of users is really high. Perhaps at the service layer, send the device location to the service, and have the service return the nearby users.
https://developer.apple.com/library/ios/documentation/CoreLo...: