Amazon.com Widgets going from Program 8.2 to 8.3
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 24, 2014, 10:41:44 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
|-+ Programming in Objective-C, 4th edition
| |-+ Chapter 8
| | |-+ going from Program 8.2 to 8.3
Pages: [1] Go Down
Print
Author Topic: going from Program 8.2 to 8.3 (Read 870 times)
ahrydberg
Newbie
*
Posts: 9






on: March 09, 2012, 03:08:32 PM

I can type in three  8.2 files  and run them.    Then to type in 8.3 I need to select "File" &" New File"  Then i can add Square.h interface file as well as Square.h implementation file  under the class "Square"  so i have  5 files .   

Now to run 8.3   I  need to overwrite the main.m file  and I loose the ability to run 8.2.    It this OK?

Am I missing something?
Logged
jimmac
Newbie
*
Posts: 13






Reply #1 on: March 09, 2012, 10:05:10 PM

I just ran into the same issue. (I'm running Xcode 4.2.1 under OS X 10.7.3 (Lion).

At first I did the same as you: I created the two new files (File menu>New>New File...), adding Square.h and Square.m. I then overwrote main.m, entering the book's Program 8.3 Test Program code. But now I could no longer run the code that had been in Program 8.2.

Here's a neat solution:

With the original unedited (i.e without Square.h and Square.m) Program 8.2 Xcode project still open, create a new Xcode project (using the File menu>New>NewProject... command) and name it Program 8.3.

Leaving that new Program 8.3 project window open, go to the (still open) Program 8.2 project window and select the Rectangle.h and Rectangle.m icons in the Project Navigator side bar. Now click and drag those icons and drop them onto the corresponding area in the Program 8.3 project window. In the drop-down window that appears when you drop the icons, put a check in the "Copy items into destination group's folder (if needed)" option and click the "Finish" button.

Now you will have the Rectangle.h and Rectangle.m files copied into your new Program 8.3 project. Next create the Square.h and Square.m in the Program 8.3 project using the File menu>New>New File... command. Edit these two new files, edit the default main.m file and the result is a Program 8.3 project with a still-intact Program 8.2 project.

Instead of the select icons/drag/drop methodology, you can apparently accomplish the same end result using the File menu command "Add files to 'Program 8.3" when you have the newly created Program 8.3 window open. Just navigate to the Program 8.2 project folder in the selection window that appears) and select the file(s) you want to copy (you can select more than one!) and again enable the "Copy items into destination group's folder (if needed)" option.

Cheers,

Jim
Logged
arydberg
Newbie
*
Posts: 6


Email




Reply #2 on: March 11, 2012, 03:32:33 PM

Thanks for the help.    I think either method would work.  I am running Xcode 4.2.1 and Lion too.   

ALSO 
To my mind it seems advantageous to erase the" (void) setWidth: (int) w andHeight : (int) "  line from  the interface file ( page 156)  as both width and height are automatically set and retrieved  by the @property and @synthesize statements.   

ps  it look like we need to help each other.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #3 on: March 12, 2012, 02:49:15 PM

The setWidth:andHeight: method is a convenience method.   There are many methods in the frameworks that shorten the task by allowing several properties to be set with a single method call.    This can make the code more readable, as well as reducing its length.  Purely subjective.

Cheers,

Steve
Logged
arydberg
Newbie
*
Posts: 6


Email




Reply #4 on: March 14, 2012, 10:47:14 AM

That is very good for adding readability but in a teaching environment when people are having difficulty grasping the main points adding extra operations  adds much to the confusion.    You need to teach only basics and let the shortcuts etc.  come later ( imho).   

Teaching is a very patient boring  slow process.    It is much more fun to throw in everything you know about the subject.   The result of this is to teach people how dumb they are and is worse that not teaching at all.   
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.