Women in Technology

Hear us Roar



Article:
  Adding Spit and Polish to Your Cocoa App
Subject:   Didn't Compile
Date:   2002-06-14 16:47:13
From:   johnts
After the first changes, when the article said to compile and try it, I got syntax errors, even after copying the code from the page. I had to change it to:


- (BOOL)application:(NSApplication *)theApplication
openFile:(NSString *)filename
{
NSDocumentController *dc;
id doc;
dc = [NSDocumentController sharedDocumentController];
doc = [dc openDocumentWithContentsOfFile:filename display:YES];
return ( doc != nil);



}


(it complained about the declaration of doc as it was.)

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Michael Beam photo Didn't Compile
    2002-06-17 19:19:32  Michael Beam | O'Reilly Author [View]

    Whoops! My mistake. You are absolutely correct. I absent mindedly changed it so that:

    NSDocumentController *dc = [NSDocumentController sharedDocumentController];

    became:

    NSDocumentController *dc;
    dc = [NSDocumentController sharedDocumentController];

    b/c the original was too wide. I'll get that fixed. Thanks for spotting it!

    Mike
    • order of statements in method
      2002-06-19 22:13:44  psheldon [View]

      I think what you both understand I shall try to put in words. Declaration/assignment can't follow an assignment. The revision Mike made to fit in the html column didn't work for us in the code because it broke that syntax rule.
      Actually, I think I need mistakes like this to find out I have it in me to hypothesize what is going wrong from the error messages. I have to get confidence I can build code when I don't have a column to follow and I'm more in the dark.