Cocoa obj-c method invocation problem

FreeKQuency23
Unregistered
 
Post: #1
Ok,
Im totally baffled here.

I have an interface communicating with a controller which talks to a NSOpengGLView class which talks to a particle engine class.

I am essentially using the exact same setup as the green triangle tutorial that apple wrote to introduce opengl and cocoa with the addition of a cstyle pointer to my particle engine declared in the interface and initialized in the init function.

I added an NSSlider and can get the values all the way down to my NSOpenGLView but I added a function call to this class to pass these values to my particle engine, and am hitting a brick wall: The function in NSOpenGLView class will not call my function from the particle engine class, but only in this one function!!! It gets called from everywhere else in the class. All other functions can call it. What the hell??????

here is the function im trying to call (its in particles.h):
- (void) forceADJ: (int)force adjustment: (float)adj ;

I am trying to call it from this function which gets called by the controller class when a slider gets moved (in NSOpenGLView class):

- (void) adjustForces: (int)type amount: (float)amt {
[pEngine forceADJ:type adjustment:amt];
}

the pEngine object gets declared in the interface as a pointer to my particles class like this.
particles *pEngine;
and initialized in the initwithcoder method (from green triangle tutorial).

I thought maybe i need an id object instead. Im new to obj-c, but the xcode debugger wouldnt even step into the function call.
Anyone have any ideas?
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #2
Might the problem be in your controller class? Where does adjustForces:amount: get called from?
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #3
Debugging should be a matter of setting a breakpoint in -adjustForces:amount: of your NSOpenGLView subclass. Make sure you are in "Development" build mode for the target (as opposed to "Release").

If you can't make that work, maybe splatter NSLog()'s everywhere and watch your console while you tweak the slider.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #4
Make sure that the pointer to pEngine is initilized in your program. I once wrote a piece of code but forgot to initialize the variable I was calling methods on, so nothing appeared to happen. I got confused because Objective-C treats messages to Nil as valid.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa/OpenGL drawing full-screen problem ultitech 5 8,263 Jan 13, 2011 01:11 PM
Last Post: SethWillits
  Please help me with problem (OpenGl\Cocoa\Objective-C) wyrmmage 4 3,441 Aug 20, 2006 05:48 PM
Last Post: wyrmmage
  [Cocoa] Problem with keyDown Criollo 4 4,195 Dec 13, 2003 06:38 PM
Last Post: Tycho