Hello,
I am working on an application with Objective-C and Cocoa. I've gotten myself in a peculiar predicament. I have an NSView on an NSWindow. In the NSView's mouseDown: method I call a class method for another class.
Now jump over to this other class. The class method I called from the other class needs to do this: (webView is an object in this class)
Unfortunately, being a class method it can't call upon objects inside the class to perform methods.
I then (perhaps foolishly) came up with the idea on crafting a function to call from the class method. I then came to the same problem -- I can't call methods upon objects again. So I built an instance method to call from the function. Which I still can't do because I get 'undefined identifier self'.
This whole thing can be best explained by this diagram:
NSVIEW SUBCLASS CLASS
DHSwipeClipView CLASS
How can I call the instance method from the class method?
The premise of the question is how can I call the instance method from the class method?
Hopefully it isn't too difficult to understand. Any Help is Appreciated!
I am working on an application with Objective-C and Cocoa. I've gotten myself in a peculiar predicament. I have an NSView on an NSWindow. In the NSView's mouseDown: method I call a class method for another class.
Now jump over to this other class. The class method I called from the other class needs to do this: (webView is an object in this class)
Code:
[self.webView setHidden:TRUE];
Unfortunately, being a class method it can't call upon objects inside the class to perform methods.
I then (perhaps foolishly) came up with the idea on crafting a function to call from the class method. I then came to the same problem -- I can't call methods upon objects again. So I built an instance method to call from the function. Which I still can't do because I get 'undefined identifier self'.
This whole thing can be best explained by this diagram:
NSVIEW SUBCLASS CLASS
Code:
[DHSwipeClipView openInfoPane];
DHSwipeClipView CLASS
Code:
+(void)openInfoPane{
NSLog(@"To the function!");
openInfoPaneFunction();
}
void openInfoPaneFunction(){
NSLog(@"To the instance method!");
//I CAN'T CALL THE openInfoPaneMethod here!!
}
-(void)openInfoPaneMethod{
[self.webView setHidden:TRUE];
}
How can I call the instance method from the class method?
The premise of the question is how can I call the instance method from the class method?
Hopefully it isn't too difficult to understand. Any Help is Appreciated!