error: cannot find interface declaration for 'NXConstantString'

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

  1. jeremyn9 macrumors newbie

    Jan 5, 2009

    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.


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

    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;

  2. HiRez macrumors 603


    Jan 6, 2004
    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).
  3. jeremyn9 thread starter macrumors newbie

    Jan 5, 2009
    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

    Apr 1, 2006

    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:


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

    Hope this helps.


    Steve Kochan

Share This Page