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

jejlmd

macrumors newbie
Original poster
Jul 11, 2008
1
0
Ohio
I am desperately trying to learn COCOA, by first learning Objective-C. In Stephen Kochan's book "Programming in Objective-C", I have tried the following code lifting verbatim code from his text, which does run without error, but the following code tutorial produces the error message: 'Point' redeclared as a different kind of symbol:

#import <stdio.h>

// ------ @interface section ------

@interface Point: NSObject
{
int pointX;
int pointY;
}

any suggestions anybody??

Thanks!
 
If you look at the error line that should appear before the one you're looking at, it should tell you where the previous declaration with the same name is.

Basically, this means that the namespace already has something called "Point" and you can't use it because that would introduce an ambiguity. Rename it to something else. A common practice is to use a two or three letter prefix that will be somewhat unique to your project. For example, Cocoa uses 'NS'.
 
Yes, MacTypes.h already defines Point, and may be included at some deep level. Try using a prefix like kpua said.
 
For very common object names, I usually use something like "MyPoint" , or for an app or library named foo: "FooPoint" . Makes it easier to search for it without also getting a bunch of foundation and other library's various Point types.
 
using XCode??

I ran into the same error and thanks to the response by aLoC, you can continue on if you rename your class from Point to something thing Coordinates.

Or go the the file progName_Prefix.pch and make sure you comment out the import of teh Cocoa.h file. If you comment out the loading of the Cocoa framework, you can then use the name "Point" as your class name definition.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.