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

jeremyn9

macrumors newbie
Original poster
Jan 5, 2009
10
0
Hi


I am trying a code Kochan's book below and experience an error i cannot resolve:
error : cannot find interface declaration for 'NXConstantString'. This happens a few times, whenever NSLog line is called and whenever fileHandleForReadingAtPath is called.

can someone kindly explain y? Im using cygwin and pasted over the foundation libraries from GNUStep.


#import<Foundation/NSObject.h>
#import<Foundation/NSString.h>
#import<Foundation/NSFileHandle.h>
#import<Foundation/NSFileManager.h>
#import<Foundation/NSAutoreleasePool.h>
#import<Foundation/NSData.h>

int
main (int argc, const char *argv[])
{

NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
NSFileHandle *inFile,*outFile;
NSData *buffer;

//open the file test file for reading

inFile = [NSFileHandle
fileHandleForReadingAtPath:mad: "testfile"];

if (inFile==nil)
{ NSLog (@"Open of testfile for reading failed\n");
return 1;
}

//Create the output file first if necessary

[[NSFileManager defaultManager] createFileAtPath: @"testout"
contents:nil attributes: nil];

//Now open outfile for writing

outFile=[NSFileHandle fileHandleForWritingAtPath: @ "testout"];

if(outFile==nil)
{
NSLog(@"Open of Testout for writing failed\n");
return 2;
}

//Truncate the output file since it may contain data

[outFile truncateFileAtOffset: 0];

//Read the data from inFile and write it to outFile

buffer = [inFile readDataToEndOfFile];

[outFile writeData: buffer];

//Close the two files

[inFile closeFile];
[outFile closeFile];

[pool release];
return 0;


}
thanks
jeremy
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
Does this or this help?

I don't think this is your problem, but in a couple of those lines you appear to have a space between the @ and the first quote, I think they need to be adjacent to each other for an Obj-C string constant (if they don't need to be, they always are as a matter of style).
 

jeremyn9

macrumors newbie
Original poster
Jan 5, 2009
10
0
I'm wondering if the file type to be read needs to be of a certain type?

as in txt file or something?
 

skochan

macrumors regular
Apr 1, 2006
150
0
California
Hi


I am trying a code Kochan's book below and experience an error i cannot resolve:
error : cannot find interface declaration for 'NXConstantString'. This happens a few times, whenever NSLog line is called and whenever fileHandleForReadingAtPath is called.

can someone kindly explain y? Im using cygwin and pasted over the foundation libraries from GNUStep.

Jeremy,

It's been a few years since I've used Cygwin for Objective-C development, but did you check on Page 311 (first edition) for the proper command-line option to use:

-fconstant-string-class=NSConstantString

without this command line option, the compiler treats constant string objects as class type NXConstantString.

Hope this helps.

Cheers,

Steve Kochan
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.