Ok so i am just starting out on writing code and i am having problems due to my lack of programming knowledge. I have gotten this code from the book,"Beginning iphone Development" so this code is not my work but Dave Mark, and Jeff LaMarche work.
my question is now that i have gotten the location data i want to create a method which can access the method which contains locationManager.
Code:
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
if(startingPoint == nil)
self.startingPoint = newLocation;
NSString *latString = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.latitude];
latLabel.text = latString;
[latString release];
NSString *lonString = [[NSString alloc] initWithFormat:@"%g°", newLocation.coordinate.longitude];
lonLabel.text = lonString;
[lonString release];
NSString *horizontalAccuracyString = [[NSString alloc] initWithFormat:@"%gm", newLocation.horizontalAccuracy];
horizontalAccuracyLabel.text = horizontalAccuracyString;
[horizontalAccuracyString release];
NSString *altitudeString = [[NSString alloc] initWithFormat:@"%gm", newLocation.altitude];
altitudeLabel.text = altitudeString;
[altitudeString release];
NSString *verticalAccuracyString = [[NSString alloc] initWithFormat:@"%gm", newLocation.verticalAccuracy];
verticalAccuracyLabel.text = verticalAccuracyString;
[verticalAccuracyString release];
CLLocationDistance distance = [newLocation getDistanceFrom:startingPoint];
NSString *distanceString = [[NSString alloc] initWithFormat:@"%gm", distance];
distanceTraveledLabel.text = distanceString;
[distanceString release];
}
for example my new method wants to get the current altitude then wait 10 seconds and get the altitude again, with this data i would then take the change in altitude/time(10 secs) to get how many m/s i am moving up.
//sudo code
Code:
-(IBAction)getSpeed{
getAltitude;
wait 10 seconds;
getAltitudeDelayed;
AltitudeDelayed-Altitude = changeInAltitude;
chageInAltitdue/10 = rateOfChange;
label.text = rateOfChange;
}
any help would be awesome!!