While my CarLot app seems to function fine, I notice that if I press the Add button when the previous car is still highlighted, the app crashes. Xcode goes to AppDelegate.swift and I see a message that starts with EXC_BAD_ACCESS. If I click the window first to remove the highlighting, the Add button works fine. I’ve posted a screen shot at https://dl.dropboxusercontent.com/u/24746182/Screen%20Shot%202015-08-10%20at%2010.17.17%20AM.png If I press the Add button at this point, the app crashes. This isn’t normal behavior surely? Does your app act like this? Is this something I’ve done wrong, or is it just a detail that the carLot example doesn’t address?
BTW, is there a way to paste an image directly in the post? I can’t figure out what the Img button does.
I’m not having this problem with my code. If you want to post your code to github I’ll take a look at it to see if I can figure out what’s going on.
About posting images, the moderator of each chapter’s forum has the ability to allow or disallow posting of attachments, etc. It hasn’t been allowed for this chapter.
Thanks a lot. I put my code at https://github.com/saulspatz/CarLot.git. I went through it again after reading that you don’t have this problem, and I noticed something I had overlooked before. The bolding of the first two columns if the car is on special isn’t working either, although my screen looks just like Figure 13.18 in the book, so far as I can see.
Hi Saul, the Add button has an unneeded Target binding that is causing the crash. Control-click the Add button in Interface Builder and delete that Target binding to fix it.
I’m not sure yet what’s happening with the bolding problem. Everything so far looks proper to me.
I may have mentioned this before, perhaps to someone else I helped on a similar problem with the program crashing for unknown reasons. What I do is open my project and the book’s project code in two side-by-side windows. Then I can go through swift code line-by-line, or Interface Builder objects object-by-object comparing Bindings, Connections, Settings, etc. Eventually I find something that I’ve done differently from the book and fixing that usually fixes the problem. This is after making sure the book’s code doesn’t exhibit the same problems.
Thanks again. That fixed the crashing problem. As to comparing the code with the book’s, what I’ve been doing is going back to the beginning of the chapter and trying to make sure that I’ve followed the instructions. I think I’ll try downloading the code and see if that helps.
I’m getting a crash on Add every time and am pretty frustrated.
The Add Button has a sent action to Cars, add
The Cars controller is bound managedObjectContext to File’s Owner managedObjectContext
And the File’s Owner is confirmed to be Document.xcdatamodeld
But every time I press it, NSApplication crashes in Thread One with EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). In the past, that has usually meant some miss-spelling, but at this point, I haven’t written a line of code, just specified an entity and a user interface and done the bindings.
When you bound the Cars controller to File’s Owner managedObjectContext, did you do it under Parameters and not Controller Content? And I’m assuming you followed all the steps setting up the Cars array controller. Like in the Identity inspector and so on.
My suggestion would be to review each step, and each binding. If you have done that and everything still appears correct from what the book is tell you to do and it still crashes, then I’d delete the project and start it over. There have been cases here where Xcode gets some kind of bug in there and once a project is redone, it works…even if you did the exact same thing.