Re: Executing methods in one class from within another
Re: Executing methods in one class from within another
- Subject: Re: Executing methods in one class from within another
- From: "Carlos A. Weber" <email@hidden>
- Date: Tue, 11 Jun 2002 16:34:48 -1000
On Tuesday, Jun 11, 2002, at 14:05 Pacific/Honolulu, alex wrote:
Hi,
we have problems figuring out a way to access a method in one class form within another. I have, in an earlier project, managed to do so by subclassing NSApplication which provided one central location to actually store instances of any other controller class, therefore making everything accessible easily and to every class at any time.
The documentation refers to this as some kind of no-no. I don't really understand how else to modify some instance in one class from another class without having an instance of it.
I have done some searching but didn't come up with anything useful. The documentation on NSApplication is nto very helpful. Considering that this is a question that earlier or later will pop up for everyone I hope someone could point me to where this is explained, or just explain it to me.
Alex, I am not an expert in Cocoa or OOP, but your message suggests to me that you have missed something in the process of assimilating what programming with Cocoa is all about. There is no one "way to access a method in one class form within another"; Typically, _instances_ of various classes send _messages_ back and forth to each other. When an instance receives a message, it will respond if it (or any of the classes it inherits from) has a _method_ corresponding to that message. How the various objects (instances of classes) your app manipulates communicate with each other is up to you, and depends on the structure of your app. One object might create other objects (by calling their designated initializers); an object might contain other objects (as in the case of a view containing various subviews and controls -- this kind of connection is usually established using Interface Builder). Etc, etc...
I think in order for us to help you, you will have to provide us with more detail about what specifically you are trying to accomplish (I am willing to bet that subclassing NSApplication is NOT the way to do it); but you will probably also have to do some homework of your own on the application design front: what are the objects in your application, and precisely how do they need to communicate with each other?
P.S.: Please try to avoid cross-posting to the cocoadev and macosdev lists.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.