[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: an error from the expression: CLS_ISCLASS((Class)receiver) File: sen

From: Truls Becken
Subject: Re: an error from the expression: CLS_ISCLASS((Class)receiver) File: sendmsg.c Line 321
Date: Fri, 13 Feb 2009 09:30:54 +0100

David T. Shen wrote:

> ////  AppController.h
> #ifndef _APPController_H_
> #define _APPController_H_
> #include <Foundation/NSObject.h>
> @class NSWindow;
> @class NSTextField;
> @class NSNotification;
> @class NSMenu;
> @interface AppController:NSObject
>        {
>                NSWindow *window;
>                NSTextField *label;
>        }
>        - (void) applicaitonWillFinishLaunching:(NSNotification *)not;
>        - (void) applicationDidFinishLaunching: (NSNotification *)not;
> @end
> #endif

This is more of an advice than a direct cause of errors, but we
usually don't use #ifdef _SOMETHING_H_ protection. Instead,
Objective-C has #import, which is a variant of #include that makes
sure to only include the file once. For some reason you used that in
main.m, but not anywhere else.

The other point I'd like to make is that importing <AppKit/AppKit.h>
in AppController.h would simplify things a bit. I guess it's debatable
whether this is better than declaring/importing only what is strictly
needed in the header and then import AppKit in the implementation
file, like you do now, but generally I think it's simpler to just
import AppKit in the controller header and be done with it. This would
replace the 5 classes you currently declare/import - a list which
would surely grow as you develop you application.

Also, applicationWillFinishLaunching: was spelled incorrectly in this file.

#import <AppKit/AppKit.h>

> ///// AppController.m
> #include "AppController.h"
> #include <AppKit/AppKit.h>

Following the two advices above, this now becomes:

#import "AppController.h"

> //// main.m
> #import <AppController.h>
> #import <AppKit/NSApplication.h>

Here, you need to use "AppController.h", not <AppController.h>.

Hope this helps.
- Truls

reply via email to

[Prev in Thread] Current Thread [Next in Thread]