Welcome, Guest. Please login or register.
Did you miss your activation email?
April 30, 2017, 11:38:17 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
| | |-+ Question regarding Test Program 8.3 on page 159
Pages: [1] Go Down
Author Topic: Question regarding Test Program 8.3 on page 159 (Read 1027 times)
Posts: 10

on: March 01, 2012, 06:28:28 PM

I am working through all of the programs to make sure I understand how they work and I have a question about 8.3 on page 159.  I hope someone can help.

I noticed that we do the #import <Foundation/Foundation.h> statement in the test program. 
But we also do #import "Square.h". 
"Square.h" does an import of Rectangle.h which should already include the #import <Foundation/Foundation.h>.

When I tested my program, it succeeded when only one of these imports was included but also succeeded when both of them were EXCLUDED.  So, I'm having trouble figuring out why it's there at all.
Hero Member
Posts: 3114

Reply #1 on: March 06, 2012, 02:12:27 PM

It's there because you never know where a class will be used.   There's no harm in importing a file multiple times, in fact the #import statement will prevent multiple inclusion (that is, it won't process a header file a second time if it's been previously imported).


Steve KOchan
Pages: [1] Go Up
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.