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 "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
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 "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