• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Syntax error when declaring an IBOutlet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syntax error when declaring an IBOutlet


  • Subject: Syntax error when declaring an IBOutlet
  • From: Mark Teagarden <email@hidden>
  • Date: Thu, 06 Mar 2008 12:16:46 -0600
  • Thread-topic: Syntax error when declaring an IBOutlet

Hi,

My app has three objects - world, mapview, and game, and they need to know
about each other in various combinations: mapview needs an outlet to world
and game, and game needs an outlet to world.  I've ctrl-clicked them all
together appropriately in IB, and now I'm trying to declare the IBOutlets in
code.  So in mapview.h:

#import <Cocoa/Cocoa.h>
#import "World.h"
#import "Game.h"

@interface WMapView : NSView {
    IBOutlet Game * game;
    IBOutlet World * world;
    int view_x, view_y, window;

}

This worked fine and complied correctly.  But the following code (identical,
as far as I can tell) in game.h:

#import <Cocoa/Cocoa.h>
#import "World.h"

@interface Game : NSObject {
    IBOutlet World * world;
}

Throws up: 'syntax error before World' in the IBOutlet statement.  I was
able to get around this by replacing

#import "World.h"

with

@class World

in game.h.

I have another class, Display, that gives me the same error as the one in
game.h - I've omitted it here for clarity.  Basically, the mapview.h #import
/ IBOutlet is the only one that worked correctly.

My questions are:
1.  Why does identical code work in one file and not in the others?
2.  Why should @class work when #import doesn't?  Hillegass flat out says
that the two are interchangeable.

Thanks,
Mark


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Syntax error when declaring an IBOutlet
      • From: Paul Goracke <email@hidden>
    • Re: Syntax error when declaring an IBOutlet
      • From: David <email@hidden>
  • Prev by Date: modal session before NSApplicationMain is invoked.
  • Next by Date: Re: Interface to shut down cores and/or processors?
  • Previous by thread: modal session before NSApplicationMain is invoked.
  • Next by thread: Re: Syntax error when declaring an IBOutlet
  • Index(es):
    • Date
    • Thread