Saturday, December 31, 2011

How to smash your head against a desk

    Well, I made my decision. I took the shorter path, maybe. I have decided to work through the book "Mastering Xcode 4: Develop and Design." The book is very well written and comprehensive. Instructions and examples are all very clear, just make sure you look very carefully at the provided images of various parts of the Xcode software to see what "view options" are selected. If you are not familiar with Xcode, and I am not, some of terminology will take a little getting used to.

    I am so glad I didn't try this on a regular e-ink Kindle. The full color screen shots are very helpful. In fact, by using the Kindle app on a dedicated screen I was able to get some very clear images of what I was suppose to be looking at during various examples. I even managed to get  as far as 29% of the way through the book before I wanted to smash my head against the desk.

    The fault is partly the lack of information in the book, and partly the fault of Apple changing things in osX Lion and Xcode 4.

    Immediately following Figure 10.13 "The Due column's bindings settings", is a section called "Taking the UI for a test drive." At this point you have a working "To-Do" application that will save persistent data even after the application has quit. It does this with MOM, the Managed Object Model. Its sort of a built-in mini-database for your application. Its actually very slick and fairly easy to use. Until I was done with the test drive anyway.

    The 3 last sentences of this part read: "It's just as easy to add another attribute to the ToDoItem entity. To-dos need a completion check box. To do this, you could add a "completed" Boolean attribute to the ToDoItem entity and add another table column with a check box cell."

    Thats it. End of section. In fact the next section is "Creating Custom Classes". It all sounds so simple doesn't it. Trying to accomplish this one task had me up until o'dark thirty looking for answers. Let me explain.

    When you add a "MOM" to your application, it is created by your application at startup, unless one already exists. In that case it will just pull data from the "MOM" and populate your information as you have programmed it too. Unless you make changes to the "MOM" after you have run your application that is. After adding the "completed" attribute I got the following error:

    The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store.

    I received this no matter what I tried. So, I turned to Google for answers. If you are using Xcode 3 and you are running osX10.6 Snow Leopard, all you need to delete the file: ~/Library/Application Support/[Your Apps Name]/[Your Apps Name.xml]. I found this all over the internet. It seemed to a common enough problem in Xcode that a lot of people posted information about it.

    In XCode 4, which runs on osX 10.7 Lion however, no such file exists. I spent hours looking for this file, not even spotlight could find it. I was ready to smash my head against my desk. My wife was getting very cross with me because I hadn't yet gone to bed. Even my dogs were getting weary of my stubbornness to find the solution. Yet I persisted and once again, Google was my friend. A stubborn friend who should just be able to guess at the information I am seeking, but a friend nevertheless.

    On the blog: Extelligent Cocoa, I found this post. Someone else had been just as frustrated as me at what was happening. If you look on the right side of his blog, you will see post called Zombie File Found. That was the answer.

    In short, the file you need to delete is in a hidden folder. You will to do the "ShowAllFiles" trick for Finder to even get to it. The file is located at ~/[UserHomeFolder]/Library/[AppName]/[AppName.storedate]

    This is my first real attempt at learning to write software for the Mac. I hod forgotten how very frustrating it can be to try to solve what seems should be a simple problem. This is not the first time I have encountered such problems. Once again, the real issue was the absence of a small, yet vital, piece of information.

    It has been my experience in programming that this is often the case. In fact, it because you know what you should be looking for, and you know it shouldn't be as hard as you are making it that makes the whole process so maddening. Damn i've missed that feeling.

    Happy New Year!

No comments:

Post a Comment