Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
March 18, 2018, 02:51:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
Author Topic: Question regarding Test Program 8.3 on page 159  (Read 1196 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:  

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 ゥ 2009 All rights reserved.