Solution for newLocation problem in 6.1 on pg 120


I am fairly new to ios programming let alone objected based programming. so when i found out this simple solution to the this problem i was geeked and excited really want to thank the authors of the book because without reading it through the first i wouldnt have understood it at lol but here is the simple solution i found for the problem on pg 120 enjoy!!

as you all have come to find out the old update location code has been removed and wont work in the complier

[code] - (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation


i have messed around with it trying to remember the lessons in the book and figure out all the code really asks for is a location and in reading this chapter we learned how to create a location using the class " CLLocation" all the newLocation method in that protocol did was establish this location so we can create the newLocation object by using CLLocation so we can continue the chapter all you have to do is the following.

change you code to create the instance of newLocation as so

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
	NSLog(@"%@", [locations lastObject]);
	CLLocation *newLocation = [[CLLocation alloc] init];
	newLocation = [locations lastObject];
	NSTimeInterval t = [[newLocation timestamp] timeIntervalSinceNow];
	if (t < -180) {
		//this data is cached stop looking
[self foundLocation:newLocation];


i got to these steps by remembering what i learned the first i read the book and the objective-c book by big nerd ranch. the array is a list and each item is added to that list the newest addition to that list would be the last entry so i decided to access the array " locations" and pull out the last entry i checked to see if it was accurate by using “NSLOG” then proceeded to make and instance of CLLocation named it “newLocation” then i set “newLocation” to = " [locations lastObject]" so i could further more proceed with the book.

i know it doesnt seem like a big fix but it was this little moment that made me realize i am actually learning what this book is trying to convey and teach and showed me i have come a long way baby steps for sure but motivation to troubleshoot something like this lol


Hi millienheir,

my solution is no different that yours, but my approach was a little different. After I saw that the method needed was deprecated, I consulted with
CLLocationManagerDelegate Protocol Reference :smiley:


I don’t think it is needed to create an instance of the newLocation object.

This should be sufficient:

CLLocation *newLocation = [locations lastObject];
NSLog(@"%@", newLocation);