ios - display value in UIlabel from CLLocation manager -



ios - display value in UIlabel from CLLocation manager -

i have next code, going form backbone of gps app.

i trying location (lat & long) , speed, , display value in label.

here code:

- (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. locationmanager = [[cllocationmanager alloc]init]; locationmanager.delegate=self; [locationmanager startupdatinglocation]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { nslog(@"didupdatetolocation: %@", newlocation); cllocation *currentlocation = newlocation; if (currentlocation != nil) { longditute = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.longitude]; latitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.latitude]; nsstring *gpsspeed = [nsstring stringwithformat: @"%f",newlocation.speed]; speedlable.text= gpsspeed; latitudelable.text = latitude; longitudelabel.text = longditute; } }

to mind, should see values printed in labels, there never seems changes. show default "label" text. can suggest i've gone wrong, , how prepare it?

much appreciated.

i need post code, i'm using new reply rather next comment @user2766755 's answer.

the parameter oldlocation no longer sent in new method. weren't using oldlocation, shouldn't need it.

additionally, instead of getting single location, newlocation, nsarray of new locations. utilize nsarray method lastobject recent location object array.

to recent location in variable newlocation utilize code this:

- (void)locationmanager:(cllocationmanager *) manager didupdatelocations:(nsarray *) locations { cllocation *newlocation = [locations lastobject]; //the rest of code goes here... }

ios objective-c cllocationmanager

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -