Sorry for my poor English!
I wrote a script on Pythonista to get my current coordinate within CLLoctionManagerDelegate’s method.
The coordinate of type CllocationCorrdinate2D is a structure.I don’t know how to get the latitude and latitude.Have Someone ever do that before?Thx for you reply!
The following code is what I did right now,and it doesn’t get the right result:
from objc_util import *
from location import *
class CLLocationCoordinate2D (Structure):
_fields_ = [('latitude', c_double), ('longitude', c_double)]
def locationManager_didUpdateHeading_(_self,_cmd,manager,newheading):
heading=newheading
#print(heading)
def locationManager_didUpdateLocations_(_self,_cmd,manager,locations):
locations=ObjCInstance(locations)
print(locations[0].coordinate().latitude)
manager=ObjCInstance(manager)
manager.stopUpdatingLocation()
methods=[locationManager_didUpdateHeading_,locationManager_didUpdateLocations_]
protocols=['CLLocationManagerDelegate']
LMD=create_objc_class('Delegate',NSObject,methods=methods,protocols=protocols)
CLLocationManager=ObjCClass('CLLocationManager')
locationManager=CLLocationManager.alloc().init()
delegate=LMD.alloc().init()
locationManager.setDelegate(delegate)
#locationManager.startUpdatingHeading()
locationManager.startUpdatingLocation()
coor=CLLocationCoordinate2D(30.1,104)
#print(coor.latitude)