How should this project be started without using Windows Based Application?
How should this project be started without using Windows Based Application?
I too am having this issue. I upgraded to XCode 4.2. Oops?
Going to have to upgrade eventually and well before a 3rd edition.
Without a simple workaround I’ll be returning the book as I already have the first edition.
Yes, it’s not meant for the beta. And Apple really decided to screw this one up.
Open main.m. Find the function UIApplicationMain(), and make the last argument nil.
Open QuizAppDelegate.h, put an IBOutlet in front of the window property.
You can create a new Window XIB from the templates, name it MainWindow.
Make the File’s Owner Identity a UIApplication (by selecting it, opening the utilities area, selecting the Identity inspector, and changing the Custom Class field).
Add a NSObject to the XIB Object’s list, change the custom class of this object to QuizAppDelegate (the same way you did for the File’s Owner).
Connect the window outlet of the QuizAppDelegate to the window object.
Connect the delegate outlet of the File’s Owner to the QuizAppDelegate.
Select the project. Select the Quiz target. Enter MainWindow into the Main Interface field.
Now, select the Quiz project. Then select build settings. Search for “Automatic reference” and set both settings to “No”.
And finally, remove the line from QuizAppDelegate.m that looks like this:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Then you are good to go.
Awesome, thanks! I’ll give that a shot.
Sorry for the trouble…still seem to be at a loss…
retVal = UIApplicationMain(argc, argv, nil, nil);
No problems here. Should this have retain as in the book? Its default is (strong, nonatomic)
No problem here
Changed the Custom Class for the File’s Owner to UIApplication
Added the NSObject to the XIB Object’s list and changed the label to QuizAppDelegate (Also tried Quiz App Delegate). Right clicking on the QuizAppDelegate object brings up a window with:
New Referencing Outlet
Referencing Outlet Collections
New Referencing Outlet Collections
I declared the variables and methods in QuizAppDelegate.h, they should have appeared in the QuizAppDelegate object, correct?
Should this be connecting the File’s Owner delegate to the window object?
Added MainWindow to the Main Interface field.
Any help would be great. Thanks
Yes, that is correct, my fault, was going off memory.
It should be retain, but you will also have to change your project to not use automatic reference counting. In fact, you will have to change all of your projects not to use automatic reference counting. (The book was already finished before automatic referencing counting was unveiled.) You can do this by selecting the project from the project navigator, choosing the project in the editor area, and choosing Build Settings. Then, find “Objective-C Automatic Reference Counting” option and set it to No.
You’ll have to change it to QuizAppDelegate in the Identity inspector just like you did for the File’s Owner.
Nope, once you change the Custom Class of the NSObject to QuizAppDelegate, that outlet will appear.
However, I did forget one step (apologies): connect the delegate outlet of the File’s Owner to the QuizAppDelegate.
Also, keep in mind we didn’t have a chance to see 4.2 before the book was written. There were a number of new feature added and the templates were changed again, so you’ll run into similar issues throughout the book. Such is the life of keeping up with Apple.
Thanks alot Joe, everything made sense and built properly (yay!).
One strange problem…all connections appear to be correct, but neither of the IBAction methods get called. I added debug messages to the init, showQuestion, and showAnswer. init debug message displays in the log window, but the actions do not.
Is it possible Apple changed IBAction?
Figured out the problem. One of the auto-generated methods was preventing the actions from functioning.
As soon as I removed this the program worked as expected.
How would this prevent the actions from working?
Ah, yes, thank you, I’ll add that to the list.
It prevents things from working because it creates another window and places it on top of the window you get from the XIB file. This window is transparent and will eat the touches of the window beneath it. In other words, you have two windows and you can’t interact with the one from the XIB file.
Excellent! Thanks much for the help.
Well done Joe, for fixing up the template for our use. Now that you have one suitable for the exercises in the book, could you post it somewhere for downloading? Perhaps I should be able to follow the instructions, but I can’t even get started with step one, since I don’t know which 4.2 template you started with. And I’m sure I’ll have a dozen more problems after that, being so new to stuff. The template would be extremely useful to readers, since the Style Choices section mentioned it is the basis of most projects in the book.
Someone on the Apple forums unapologetically suggested starting with an Empty app, and Learning all the stuff you need to learn, since you’re going to need to learn it sometime! That sounds like the opposite of your philosophy of concepts introduced as they are needed. I’d like to make it through Chapter 1 without tearing my hair out.
thanks for posting that link to wrap up this topic.
I’ve just purchased your book. I’m very excited to start using it! That said, I’ve been learning Objective-C using another book and I’m quite used to the Xcode 4.2 interface (hence my not using 4.0, 4.1, etc).
My question is about step 5:
How do I do that? In the book it says I may feel like a monkey copying code (which I do), but this set of instructions seems to assume a higher level of competence than that of a monkey. Help!
To add the NSObject:
Select the .xib file. In View > Utilities > Object Library, search for an NSObject (using the search box at the very bottom), and drag the Object to the Objects section of the gutter (or whatever you want to call the thing that lists the contents of the .xib).
To change the custom class:
Select the new NSObject, then View > Utilities > Identity Inspector. In the Custom Class section at the top, change the class to QuizAppDelegate.
For the monkey feeling (which I’m guessing a lot of people get initially; I did as well), the important thing is that your brain gets used to the pattern and relays this to your fingers, so after awhile you’re like “Yeah, yeah; create the IBOutlets, create and synthesize the properties, add the IBActions, make the connections…I could do this in my sleep.” That’s the point of actually doing it.
You COULD just copy-and-paste the code from the solution code, or worse, just sit back in your easy chair and read the book with no hands-on time. After all, it would mostly make sense. But then when you sat down to actually create your own app, you’d be lucky to get even the initial Quiz app working without going back to the book.
Thank you so much! I appreciate the need for the monkey-see approach, I was just COMPLETELY stuck on how to add the NSObject. Thanks for clarifying! I’m off to code!
Is there an update on this issue. Xcode 4.2 is now out of beta and released along with iOS 5. I have just installed and also found no Window-based template for iOS. Every iOS book or class I have been through uses the Window-based template for the majority of projects. I have almost completed the Stanford CS193 course on iTunes U and they used it almost exclusively. Has anyone raised this with Apple? Have they acknowledged the issue? I have seen a number of comments telling people not to use beta code but now it is in GA everyone will be using it. I was forced to upgrade following the Lion upgrade as Xcode 4.0 will not run on Lion.
Surely the right approach is to find out why it has been dropped and if it can be added back? I can’t believe that a template that appears to be so commonly used was just dropped by Apple without warning. I have found a number of posts on the internet asking why it is missing and no answers anywhere.
Ok, so I have read the comments suggesting we raise this as a bug with Apple so I went to the section of their site where you log bugs and I got an error message say there was a bug with the bug reporter, this is getting silly. For some reason I can’t get onto the developer forums either. I feel like I am going crazy. Is anyone else having similar problems.
I can’t get past this screen - developer.apple.com/devforums/
I just started going through this book today and was disappointed, it is already out of date. I am not sure who to be more annoyed at, the authors for putting out a “second” edition so close to the release of a new iOS version or Apple for changing their new project template.
I am not sure why you would tell us to turn off the ARC? From everything i have read on Apple this seems to be a tremendous improvement, am i missing something? Can’t we just ignore all the allocation/deallocation instructions in the book?