Monday, August 29, 2011

Renaming in XCode4 - don't do it.

Ok, yesterday we managed to get as far as getting the question view controller successfully showing after being called from our initial start view controller. Next we're going to do a bit of renaming of xib files, which proved to be a bit problematic. Now that we have that piece working, it will be a good time to give it another try.

Ok, after consulting with SO, it looks like one way to do it is to delete reference to the file from the project, but not the file itself. Then, rename and copy the file back in to its correct location from file finder.

That actually works with moving files as well. I had originally created the StartController in the outside of "classes". moving them in the project doesn't move them on disk, which is odd.

Uh-oh. When I renamed the StartController, it went fine. But, when I renamed the Root Controller, the question controller showed up as a blank. Worse, when I went to the backup, I still get a blank screen. Ouch.

This is a setback. I had the white screen before - and I have the feeling it turned out to be something simple - but I totally forget what it was. The white screen is an awful thing. What could possible be the cause of it? What's really bugging me is the backup doesn't work; neither one which I took this morning, which were both working fine. Which generally means I was just getting lucky with what I was doing before, like a memory leak which didn't show up till later, or something.

This is a sudden "iceburg". These are showstopper errors which basically fall into areas which you have no understanding of, and are not really in your own code. So much of it is "hidden" like an iceburg. Plus the immovability, and size of it.

I'm sure the problem has to do with this renaming of the root. I just don't know why it affects the backups.

Well, what to do? If I go way back to backup 3, I can see the question display again. It might be good to just start from there. I just don't get what went wrong. That's the frustrating thing. What if it happens again?

This is the difficult part. Ok. Just accept the loss. Redoing it will be a good review. I alway like to start with something that works. So, let's just go back to where we can see the display - and hope like hell it doesn't happen again.

1. Copy the last working project to a new folder.

Done. Test. Ok.

I should really figure out how this snapshot works, because obviously my backup strategy isn't so hot. Well, I created one - it's file create snapshot. I should really just do source control. But I'm keen to get this thing back to where I was.

Ok. So, what did I do first? I think I created the StartController. File, new, create UIVeiwController subclass, specify it goes into classes.

Ok, that's done. Now; what was next? I updated the start controller nib with a button.

Ok, that's in there now. Next is to have it called from the QuizAppDelegate. The QuizAppDelegate will need a reference to it.

Ok, substituting the code is the easy part, for the Quiz App Delegate. Now, I'd like to remember how to interface with the nib.

So, I think it needs a to have a connection made to the start view controller's view's. Yes, that's via the IBOutlet.

So, that view needs to exist as an object in the main window's nib file.

Uh-oh. A crash - right at the main. NSUnknownKeyException. It's apparently one of my renames backfiring on me again.

Ok, one more try, start again.

Ok, I've got it to the point where I'm ready to substitute this:

navController.viewControllers = [NSArray arrayWithObject:questionController];

with this:

navController.viewControllers = [NSArray arrayWithObject:startController];


And it works.

Ok, now to have the new StartController call the QuestionController.

And, we're back where we started out this morning. It was a good review. Still, it takes time.

Ok. No more renaming.

No comments:

Post a Comment