• 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
Re: creating a controller class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating a controller class


  • Subject: Re: creating a controller class
  • From: Dominik Pich <email@hidden>
  • Date: Wed, 18 Jul 2007 09:01:30 +0200

Forward declare GUIController in ImageMaker.h
so you say : hey there is a class coming

AFAIK your problem is: GUI includes IMG IMG includes GUI
you have a circular dependance

!?

Regards,
Dominik

Am 18.07.2007 um 07:14 schrieb Jeremy Rotsztain:


my apologies, i thought that i'd simplify the problem, because the application is far too large to post to the forum
so i'll expand a little bit and show some code.


the controller class (GUIController) communicates between the GUI and an instance of the ImageMaker class, which generates images algorithmically.

the GUI has a NSImageView that displays NSImages. ImageMaker tells GUIController to display the images in the GUI whenever the composition process is complete using a method called displayPainting.

i recently added a button to the GUI (and another IBOutlet - ImageMaker *mainApplication) to communicate to the ImageMaker class (see the savePainting methods in both classes), prompting the ImageMaker class to save the current image to disk.

when i tried importing ImageMaker.h into ImageController, i received an error saying ".../GUIController.h:15: error: parse error before 'ImageMaker'.

hopefully the code below will help to clarify the problems that i'm running into.

jeremy


------------------- ImageMaker.h --------------------------------

#import "GUIController .h"

@interface GUIController : NSObject {

	NSImage *currentImage;
	IBOutlet GUIController *myGUIController;
}

- (void) generatePainting;
- (void) savePainting;
- (void) displayPainting;


@end

------------------- ImageMaker.m --------------------------------

#import "ImageMaker.h"

@implementation ImageMaker

- (void) generatePainting {

 	myNSImage = [[ NSImage alloc ] initWithSize:NSMakeSize(320, 240) ];
}

- (void) displayPainting  {

	[ myGUIController displayPainting:myNSImage ];
}

- (void) savePainting {


	NSData *TIFFData = [ myNSImage TIFFRepresentation ];
	[TIFFData writeToFile:@"Users/Jeremy/Desktop" atomically:YES];
}


@end


------------------- GUIController.h --------------------------------

#import "ImageMaker.h" <-- throws an error

@interface GUIController : NSWindowController {

	IBOutlet ImageMaker *mainApplication;
	IBOutlet NSImageView * sourceImage;
}

- (IBAction) savePainting;
- (void) displayPainting;

@end

------------------- GUIController.m --------------------------------

#import "GUIController .h"

@implementation GUIController

- (IBAction) savePainting: (id)sender {

	[ mainApplication savePainting ];
}

- (void) displayPainting:(NSImage *) theImage {

	[ sourceImage setImage:theImage ];
}


@end


On Jul 17, 2007, at 7:08 PM, I. Savant wrote:

On Jul 17, 2007, at 6:16 PM, Jeremy Rotsztain wrote:

i've got a controller class, MyController, that is used by the main class (ImageMaker, an image generating class) to display images in the main application window.
MyController is setup as an IBOutlet for that main class.


i wanted to create a button on the gui that communicates through MyController to ImageMaker, but when i place #import "ImageMaker.h" in MyController.h, XCode throws an error.

Is it not possible to set up two way-communication between a controller and another class?


  Please give this document a read:

http://www.catb.org/~esr/faqs/smart-questions.html

Once you've done this, please provide the details you've left out. Namely, what is your overall goal, and what "error" XCode is giving you. Anything less requires a lot of patience and a crystal ball ... neither of which you're likely to find on a technical mailing list. ;-)

--
I.S.





_______________________________________________

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


_______________________________________________

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


References: 
 >creating a controller class (From: Jeremy Rotsztain <email@hidden>)
 >Re: creating a controller class (From: "I. Savant" <email@hidden>)
 >Re: creating a controller class (From: Jeremy Rotsztain <email@hidden>)

  • Prev by Date: Re: creating a controller class
  • Next by Date: Re: Data from thread to NSView, efficiently
  • Previous by thread: Re: creating a controller class
  • Next by thread: NSScreen + resolution change
  • Index(es):
    • Date
    • Thread