In More iPhone Programming book, the author does:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if ([newLocation.timestamp timeIntervalSince1970] < [NSDate timeIntervalSinceReferenceDate] - 60)
locationCoordinate = newLocation.coordinate;
return;
...
To make sure the data was taken in the last minute. Two questions:
1) What is the if statement doing. It seems like on the left hand side, you are getting the time difference in seconds between when this method fires and the 1970 date. Then on the right hand side, you get the difference in seconds between the 2001 date and now minus 60 seconds. So to me, the if statement would never be valid since the data on the left is always going to be a greater amount of seconds. Or am I understanding it wrong?
2) What does return in a void function do? Is that considered good coding here? Thx.
I don’t know what is going on here, its confusing statement, I have use something like this
It is right to put return in void method, as I don’t want to execute the statement next for some conditions..the same code can be written as
it just depends upon your need.