Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS 4 Application Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 27th, 2011, 12:47 PM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4, Dragging View Controller

Following "Try it out" for the windowBasedApp. Unfortunately, Xcode 4 not only looks different than the Xcode 3 examples in the book, but Xcode 4 doesn't function like the Xcode 3 examples in the book.

Initially couldn't build the windowBasedApp. Found that "Core Data" which was not checked by default needed to be checked.

Now trying to do step #4 on page 85, dragging a View Controller onto the MainWindow.xib window. Can drag over to the window but upon release the View Controller scoots back to the library and nothing remains. How to make the View Controller stick?

I have a screenshot but there doesn't appear to be a way on this forum to attach a JPG.

How can the XIB window be brought up in list mode with Xcode 4? The book example on page 86, figure 4-13, shows a list not a graphic.

Thanks.
Reply With Quote
  #2 (permalink)  
Old May 28th, 2011, 04:33 PM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Had to do three things to make it work with Xcode 4.

Step #4, had to drag the View Controller object from the Object Library not to the center Window but all the way to the Window object in the column of objects in the second pane from the left, with the stack of objects, File Owner, etc.

Step #9, had to manually enter the NIB name. The drop-down list was inexplicably empty.

Step #11, inside method "didFinishLaunchingWithOptions", had to addSubview using "_window" not simply "window".

I can understand Apple making functional improvements to Xcode, from 3.6 to 4.0, but these differences don't make any sense at all.
Reply With Quote
  #3 (permalink)  
Old May 31st, 2011, 02:33 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

A few points-
Core Data should not be checked. It is not used.
Concerning step #4
The window in the workspace is not the "MainWindow.xib", it is the UIWindow. The gutter area (Dock) to the left of the workspace serves the same purpose as the "MainWindow.xib" window that was present in versions of Xcode prior to Xcode 4. Both are essentially holding areas for all objects in the .xib. You can also drop the ViewController into the workspace and it will be added to the Dock (gutter). A ViewController cannot be added to a window. A ViewController's view can.

In Step #9, assuming you have created the class files and have selected the ViewController proxy in the MainWindow.xib, the class will be in the Custom Class drop down in the Identity inspector. The book (again working from the prior incarnation "Beg. iPad Development") may refer to finding it in the Attributes inspector.

Step #11. Apple is trying to compel you to use the accessor for the window, as you should, rather than directly calling the variable. (It is a private variable) If you note, they call it as follows

Code:
[self.window makeKeyAndVisible];
in the method that you add the subview. You should enter your method as
Code:
[self.window addSubview:viewController.view];
The list view is not available anymore. As I stated in a previous communication, there are two views; the default object view and the outline view.

If you haven't checked it out, you should read through the Xcode 4 transition guide, or possibly get a copy of Xcode 3.2.6 and try the projects in the earlier version as well as Xcode 4. The Xcode 4 quickstart guide should also be useful.

Bob
Reply With Quote
  #4 (permalink)  
Old May 31st, 2011, 08:29 PM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default windowBasedApp

Bob: thanks always for your help.

Regarding Core Data, when I first attempted windowBasedApp, as per Chapter 4, build failed, with some complaint about "no available environment" or something like that. I Googled the error message and got many hits though not exactly my case. Of course, the initial windowBasedApp was simply declare it with Xcode and build it; fairly idiot proof, you would think. But it flat out wouldn't build [or run]. I checked Core Data, and it built and ran. Now I create the same project w/o Core Data checked, and it still builds and runs, so I cannot duplicate the original problem.

My step #4 problem was that all previous examples of dragging something from the object library [right pane] had as its destination the center iPhone display graphic. This time something different was necessary, i.e., dragging to the gutter/dock object. When you're starting from total ignorance, as I am, these minor differences become major differences.

As for step #11, the book on page 90 suggests:

[window addSubview:viewController.view]

but for reasons not clear to me, "window" does not exist, but "_window" does. This would appear to be a nuanced difference between Xcode 3.2.6 and Xcode 4.
Reply With Quote
  #5 (permalink)  
Old May 31st, 2011, 11:36 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Concerning _window, check out the @synthesize. You will see

Code:
@synthesize window=_window;
This compels the use of the accessor, which is a good thing. You can still set the variable directly though the use of _window, but the implication is that direct assignment should be avoided. Proper and consistent use of accessors goes a long way in dealing with memory management and object-ownership issues. Getting accustomed to the conventions is a good thing, since many of the benefits of Key-Value coding require that certain conventions be followed.

This is a new convention introduced in Xcode 4. You could rewrite the @synthesize to be
Code:
@synthesize window;
and code as the book does and it will work correctly.



Bob
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a View Controller Programmatically error page 170 leo4all BOOK: Beginning iPhone SDK Programming with Objective-C 1 April 22nd, 2011 11:15 PM
Linking View Controller to Outlets & Actions Ricacomp BOOK: Beginning iPhone SDK Programming with Objective-C 2 July 23rd, 2010 11:14 PM
Assign Session variable from view or controller Alaphat ASP.NET 2.0 Professional 2 April 11th, 2008 09:37 AM
Model View Controller gpartin33324 Java GUI 0 October 4th, 2004 04:00 PM



All times are GMT -4. The time now is 11:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.