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!
 

kpua

macrumors 6502
Jul 25, 2006
294
0
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'.
 

aLoC

macrumors 6502a
Nov 10, 2006
726
0
Yes, MacTypes.h already defines Point, and may be included at some deep level. Try using a prefix like kpua said.
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
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.
 

a420aDay

macrumors newbie
Jan 5, 2009
1
0
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.