Amazon.com Widgets differences in code between xcode 3 and xcode 4?
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 19, 2014, 12:12:14 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 21 - Writing iPhone Applications
| | | |-+ differences in code between xcode 3 and xcode 4?
Pages: [1] Go Down
Print
Author Topic: differences in code between xcode 3 and xcode 4? (Read 877 times)
fgshepard
Newbie
*
Posts: 2






on: August 14, 2011, 09:46:53 AM

I'm working throught chapter21 of the 3rd edition, but i'm using xcode 3. I notice that my project doesn't have @private in place of the instance variables, and that @synthesize isn't followed by window=_window. How should I proceed? Running as is, i just get a blank simulator. I've tried adding a UILabel variable called display under the one for window, and eliminating the "=_window" part of the synthesize code, but this doesn't seem to help.

Also, I notice that when i run the simulator through interface builder, i can see the button and label, but the click event doesn't register. When I run it through xcode, i get a blank screen.

Any help much appreciated!

Frank
Logged
fgshepard
Newbie
*
Posts: 2






Reply #1 on: August 14, 2011, 11:17:18 AM

My original question is poorly worded, so I'll try to improve it:

1. I'm using xcode 3 with the examples from the 3rd edition, and I notice some changes in the code generated by xcode.

a. Where your .h file has "@private", mine has "UIWindow *window;"
b. Where your .m file has "@synthesize window = _window", mine has "@synthesize window;"

Should I change my code to match yours? If so, do i need to add "UILabel *display" to the .h file, etc.?

2. I notice that I can get the objects to appear in the simulator when run from within Interface Builder, but the touch event doesn't display the text. And when run from within xcode, i get a black screen with no objects on it.
Logged
fujilla
Global Moderator
Sr. Member
*****
Posts: 276


WWW




Reply #2 on: August 14, 2011, 11:49:26 AM

Hi Frank,

When Steve originally wrote the book based on Xcode 4.0.2 (probably), @private was included in the @interface section of the AppDelegate file.  This can be deleted as you can see on page 467.

You will be OK keeping @synthesize window.  I can't remember why apple changed this in later versions - I believe it's how they would like you to do it, however don't believe it is necessary.  If you do change it to window = _window you will also need to make sure you do this in the dealloc method.

Yes, UILabel *display needs to be in the .h file as per 468 as this is a pointer reference to an instance variable which will be used to display the result of the button being pressed.

Also, you may not have hooked up the button/label correctly in IB, which is maybe why it is not working.

If you are still having problems, I suggest you paste your code here for someone else to have a look at.

Hope this helps,
Nick
http://myfirstiphoneapp.co.uk
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.