The positioning feature in IOS, mainly in the Corelocation library, requires the location manager Cllocationmanager to do most of the things.
To use Cllocationmanager first requires an object ~ and simple settings for it, and finally the positioning function, and then start positioning, positioning success or failure will call the Proxy method return information
1 cllocationmanager *manger; 2 3 manger = [[Cllocationmanager alloc] INIT]; // initialize 4 delegate = self; // set proxy 6 7 manger.desiredaccuracy = Kcllocationaccuracybest; // positioning accuracy 8 9 [Manger Startupdatinglocation]; // start positioning
When these are set and the positioning is turned on, the proxy method is invoked after the positioning succeeds. Currently, your class must implement a proxy cllocationmanagerdelegate
There are two commonly used proxy methods, locating success and locating failure:
-(void ) Locationmanager: (Cllocationmanager * *) locations{ for (cllocation *loc in locations) {NSLog ( @ " location:%@ ,[loc description]); }} -(void ) Locationmanager: (Cllocationmanager * *) error{ NSLog ( @ " location failed, Reason:%@ " ,[err localizeddescription]); }
Detailed properties, such as precision, the detailed properties of the Cllocation class, and other proxy methods, are interested in flipping through the official documentation, which will be described in more detail later.