Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BirdInTheCity

macrumors newbie
Original poster
Feb 12, 2008
18
0
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?
 
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?
#import "PolygonShape.h" in your .m.
 
I'm new to the subject and yesterday I went throught just what you said.

In addition to doing the #import thing on your WhatATool.m file, you have to declare the class in the WhatATool.h file, before the @implementation clause:

@class PolygonShape;

This worked for me, I hope it works for you too.
 
I actually found that I had to provide the full path - not sure why, since the PolygoneShape.h file is right there in the freaking directory...
 
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?



Hi - I solved this by deleting the #import <Cocoa/Cocoa.h> on PolygonShape.h .

I figured since Cocoa.h is already imported in the Controller class, it's ok to omit this.
Neither the full path nor the "" things worked for me, only this.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.