how to get GPS Coordinates in iphone using Objective C

后端 未结 4 1092
暗喜
暗喜 2021-02-04 22:33

i want to get the GPS coordinates from iphone and send these GPS coordinates to web service. This web service, will take my GPS Coordinates and send me the location of the near

4条回答
  •  终归单人心
    2021-02-04 23:18

    1. Add CoreLocation framework to your project
    2. Create and setup an instance of CLLocationManager (e.g. set desiredAccuracy property)
    3. Set a delegate to your location manager
    4. In your delegate implement 2 methods: -didFailWithError and -didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    5. Call -startUpdatingLocation on your location manager.

    In didUpdate method you get all updates in your current location and can also check if the coordinates you get is valid for you (check horizontalAccuracy and timeStamp properties)

提交回复
热议问题