error: cannot find interface declaration for 'NXConstantString'

Discussion in 'Mac Programming' started by jeremyn9, Jan 6, 2009.

  1. jeremyn9 macrumors newbie

    Joined:
    Jan 5, 2009
    #1
    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
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    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).
     
  3. jeremyn9 thread starter macrumors newbie

    Joined:
    Jan 5, 2009
    #3
    I'm wondering if the file type to be read needs to be of a certain type?

    as in txt file or something?
     
  4. skochan macrumors regular

    Joined:
    Apr 1, 2006
    Location:
    California
    #4
    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
     

Share This Page