On Oct 5, 2009, at 12:59 PM, Jeff Diamond wrote:

This concept is so fundamental, but I've seen no specific docs about it, and I haven't succeeded with this after almost 2 years of trying an reading every tutorial and mail list on the web. As near as I understand it, what Cocoa calls "outlets" are nothing more than dynamic instance pointers set by IB that you would use just like a pointer to an object instance, and that the object instance should contain the information about what type of object it is.

Yes. An outlet, and an instance variable are exactly the same thing. All "IBOutlet" is, is a marker in your source code to let Interface Builder know that it should be interested in the associated variable. The "IBOutlet" marker doesn't change the behavior of the variable at runtime in any way.

When I try this, I get no warnings or runtime errors, but nothing happens - I see it make the call to the View method, but then it just steps right over the call without entering it. Do I need to cast this to the specific class type or something?

My goal: Have a control class call instance methods in a View class created by Interface Builder.
I am currently using XCode 3.1.

What I did:

1) Manually stub out the controller class and the View class files.
2) In IB, drag a blue cube (NSObject) to my nib folder and set it to the controller class 3) In the controller class file, define the actions and the outlet to the View object. 4) Connect the Gui objects to the Blue Cube, setting the correct methods to call from each Gui item < This part works > 5) Connect the Blue Cube to the View, setting its Outlet to the correct View class (confirmed many times) 6) When implementing the code in the control object, make method calls to the View class using the Outlet name as a pointer. <This doesn't work>

In the debugger, have you tried printing the value of the outlet variable? Are you sure it isn't nil?

Jon Hess


Any help would be wonderful. If ever I can make this work, I'm gonna put up an online tutorial that actually explains this.
- Jeff

==============================

I'm not sure how much code is relevant, and I don't want to swamp anyone. But here's my View class definition:

#import <Cocoa/Cocoa.h>

@interface MyOpenGLView : NSOpenGLView
  {
  float rotX;
  }

// Member functions:
- (void) drawRect: (NSRect) bounds ;
- (void) rotate; // Try to call from control class
- (void) resetGLView; // Try to call from control class
@end

============================
And here is the controller class code:
============================

#import <Cocoa/Cocoa.h>

@interface GuiControl : NSObject
  {
  // Send info to Gui via outlets
  IBOutlet id OpenGLViewOutlet; // My pointer to the IB View instance?
  }

// Respond to Gui actions:
-(IBAction)changeRot:(id)sender; // These work.
-(IBAction)resetView:(id)sender;

@end
============================
// ---------- And the controller implementation:
============================

#import "GuiControl.h"
#import "MyOpenGLView.h" // My own View header...

@implementation GuiControl

// Respond to Gui actions:
-(IBAction)changeRot:(id)sender
  {
[OpenGLViewOutlet rotate]; // Gets here and silently steps over, doesn't reach method (no warnings)
  }
 -(IBAction)resetView:(id)sender
  {
[OpenGLViewOutlet resetGLView]; // Gets here and silently steps over, doesn't reach method
  }

@end



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.com

This email sent to jh...@apple.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to