Capter 27 section: Pass the context

P626-631

I am receiving a strange error. I have checked and rechecked the code but still end up with this error CuurrentLocationViewController

Any help much appreciated!

BTW, Have the correct imports and also added all code to the bottom of p631

When you get an error stating that a view controller has no member named something, this is generally either because of a mistyping of the name, or because you forgot to add that particular property to the class. In your case, the complaint is about managedObjectContext in LocationDetailsViewController.

Since you haven’t provided the project code, but that would be the first thing to check. Make sure that the property is there as per the end of page 627.

If it is indeed there and the issue is not what I thought it was, then please post a link to the ZIP version of the full project and I’ll take a look.

sorry wrong file I will send in another post,

ok here is the compressed file as I don’t seem to be able to see the issue, I am sure it is simple as I understand the property is not seen but think I have added it per the book.

Thanks for the help!
MyLocations.zip (66.5 KB)

The issue is what I said might be the one in my previous reply :slight_smile: You do not have the managedObjectContext in your LocationsViewController - not CurrentLocationViewController. Do note that the book instructs you to add the same property to two separate files - LocationsViewController and CurrentLocationViewController.

You have done the latter, but not the former. That is the issue :slight_smile:

Well I knew it was something simple! and it was. I guess I was missing your initial point about LocationsViewController as the LocationsDetailsViewController is the one I have. I should have realized they were the same controller and added the new property as well as the import per your previous advice.

Thanks!

Was just reading the section, sorry I was such a goof on this one, it is right there…

No worries at all - sometimes you get so deep in the woods, that you can’t see the trees :stuck_out_tongue: It’s happened to all of us at one time or another …

I guess I am deep in the woods again…creating a custom table view cell subclass and get this error

I have attached the code here as well but when I go to look at the locations tab It seems to not know about LocationCell class.

A little guidance here would be great…
MyLocations.zip (79.2 KB)

When you get a console error about “this class is not key value coding-compliant”, usually look to the storyboard. It’s generally an outlet you had previously which is no longer there - maybe because you changed the property name.

However, that wasn’t the case here :slight_smile: It appears that there might have been some sort of an underlying change to the LocationCell.swift file that was not picked up by the storyboard. So, whenever you try to create a LocationCell instance in LocationsViewController.swift, the app would crash.

All you need to do is open the storyboard, select the LocationsScene, select the LocationCell, and then go to the Identity inspector, clear out the Class name and then set it again. It’s important to clear it out and tab out of the field first though.

Once you do that, the crash will go away.

However, I noticed another issue with your code. You will never get a location as the code is currently. For some reason, you are missing the following bit of code in CurrentLocationViewController.swift for getLocation. Without this code, you will just time out trying to get a location …

if authStatus == .notDetermined {
	locationManager.requestWhenInUseAuthorization()
	return
}

Yes, when I created the new file for LocationCell it did a little extending of the name and I caught it afterwards. I went the through the renaming process for the project, but clearly the story board did not get the update though I did go in and change it then. Clearly, as you said, removing it and leaving the entry field is important because even now when I fixed it I didn’t leave the entry cell the first time and it did not work. So I followed what you said and of course it worked!

As far as the missing code, not sure when I removed that but I remember having it in there before, good catch, thank you!

Appreciate the help, learned something new about story boards not necessarily updating with other updates!

Kary

This topic was automatically closed after 166 days. New replies are no longer allowed.