objective c - Not able to get the user's location in iOS 8 using CLLocation Manager? -
i tried user's latitude , longitude got result 0.000000 - have tried next code.
i have assign location manager variable. location manager allocated , set delegate self. checked ios 8 version validation requesting. using location start update location function.code:
locationmanager=[[cllocationmanager alloc]init]; locationmanager.delegate=self; // check before requesting, otherwise might crash in older version if ([locationmanager respondstoselector:@selector(requestwheninuseauthorization)]) { [locationmanager requestwheninuseauthorization]; } [locationmanager startupdatinglocation]; #pragma mark - cllocationmanagerdelegate -(void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations { nslog(@"locations %@",locations); cllocation*location = [locations lastobject]; nslog(@"location %f",location.coordinate.latitude); }
result:2014-10-15 11:10:20.118 good[714:25676] latitude 0.000000
make sure have added next lines nslocationwheninuseusagedescription or nslocationalwaysusagedescription in .plist file.
objective-c dictionary ios8 core-location cllocationmanager
No comments:
Post a Comment