How to get the current location of iPhone through code?

后端 未结 7 1437
野的像风
野的像风 2020-12-30 16:53

How do you get the current location of iPhone through code? I need to track the location using GPS.

7条回答
  •  庸人自扰
    2020-12-30 17:32

    If you just need to get the device's current location, using Core Location directly requires a good deal of code because you must handle the delay until the device's GPS has an accurate fix on the current location, which takes a number of seconds. (The CLLocationManager API appears to be built for apps that need continuous location updates, like turn-by-turn GPS navigation apps.)

    Instead of using CLLocationManager directly, I suggest you take a look at using an open source component such as INTULocationManager which will handle all of this work for you and make it trivially simple to request one or more discrete requests for the device's current location.

提交回复
热议问题