Shows wrong location


#1

Hey all,

Well, first let me say i am finding this chapter a bit hard. I feel like getting thrown through a lot of different classes, and one does that which requires this to do that etc, so i’m having a little hard time catching up. Is this normal, or am i in over my head? meaning i should re-read the whole chapter? Or will it clear up as i get more experience?

On to the subject, i am finding the app works fine, except for the fact that my current location is the middle of the ocean lol :slight_smile: and no, i’m not on a boat ^^ I get no errors, and it even zooms in and shows the blue dot. Just the wrong location. I am testing it on my iPhone 4

Thanks on advance
/JBJ


#2

Check out the thread here: http://forums.bignerdranch.com/viewtopic.php?f=80&t=2977. It’s the same problem you are experiencing. I just upgraded to Xcode 4.2 and am still experiencing the same problem.

I also tried getting rid of the hack in my WhereamiAppDelegate header file.

[code]@implementation CLLocationManager (TemporaryHack)

  • (void)hackLocationFix
    {
    CLLocation *location = [[CLLocation alloc] initWithLatitude:42 longitude:-50];
    [[self delegate] locationManager:self didUpdateToLocation:location fromLocation:nil];
    }

  • (void)startUpdatingLocation
    {
    [self performSelector:@selector(hackLocationFix) withObject:nil afterDelay:0.1];
    }

@end[/code]
But when I do this, the activity indicator just keeps spinning without end.


#3

I’m going to try it out on my iPad when I get the chance. As JonSanders explains, the issue arises because the GPS hardware is different when you run the app on the simulator.

[quote=“JonSanders”]djhoward, if you used the location hack that Joe wrote for those of us using the simulator (see http://forums.bignerdranch.com/viewtopic.php?f=79&t=2069) then the app worked by displaying Apple HQ.

The simulator is running on a laptop or desktop and those do not have the same GPS hardware and location services for cell towers as the iPhone (see Page 80 where the book is discussing the distanceFilter property). Thus, he had to “hardcode” coordinate values into the app to force it to see a location and thus allow the app to work when running on the simulator.

If you ran the app from the beginning on an iOS device (iPhone/iPad) then I don’t think you needed the extra code. It is helpful to note that the authors did put a note in the Introduction that stating getting fully credentialed by Apple was best because you test the app on a device. I’m only on Chapter 5 and I’ve run into two problems not being able to use my device (taking a screenshot and the location hack). I’m thinking it is time to start the ball rolling on a full Dev license![/quote]