FROM : Johnny Lundy
DATE : Thu May 15 04:54:09 2008
Just another note - the reason that I asked this is that I finally
added a second class to my project. I had never had 2 classes in a
project before because I didn't understand how to have them
communicate. Actually, I still don't - I just try everything until
something works.
I wrote the interface and implementation files, and the app would not
load. Of course, I had not instantiated the class because although I
knew that myInstance = [MyClass new]; would make an instance, I did
not know where to put this code. It seemed recursive to put it in the
implementation of itself.
So I dragged out an NSObject in IB, named it the class name, and
everything worked. I still don't understand why. I presume it was that
dragging it out instantiated it. Or maybe having an -init method
instantiated it. Class browser doesn't show instances, so can't check
there.
The reason I want a name for the instance is so I can use it as the
receiver when I send messages to it from another class's methods.
On May 14, 2008, at 9:23 PM, I. Savant wrote:
> On 15 May 2008, at 10:51 am, I. Savant wrote:
>
>>> And if I want to refer by name to that instance in my code, what is
>>> the name of the instance?
>>
>> Nothing. That is, not until you add an IBOutlet in whatever class
>> you want to connect to that instance. Say "AppController" has an
>> outlet called "thingController". You can then connect the
>> AppController's someThingController outlet to the "Some Thing
>> Controller" instance. Now, anywhere within your AppController class,
>> you can send messages to the "Some Thing Controller" instance by its
>> shiny new name:
DATE : Thu May 15 04:54:09 2008
Just another note - the reason that I asked this is that I finally
added a second class to my project. I had never had 2 classes in a
project before because I didn't understand how to have them
communicate. Actually, I still don't - I just try everything until
something works.
I wrote the interface and implementation files, and the app would not
load. Of course, I had not instantiated the class because although I
knew that myInstance = [MyClass new]; would make an instance, I did
not know where to put this code. It seemed recursive to put it in the
implementation of itself.
So I dragged out an NSObject in IB, named it the class name, and
everything worked. I still don't understand why. I presume it was that
dragging it out instantiated it. Or maybe having an -init method
instantiated it. Class browser doesn't show instances, so can't check
there.
The reason I want a name for the instance is so I can use it as the
receiver when I send messages to it from another class's methods.
On May 14, 2008, at 9:23 PM, I. Savant wrote:
> On 15 May 2008, at 10:51 am, I. Savant wrote:
>
>>> And if I want to refer by name to that instance in my code, what is
>>> the name of the instance?
>>
>> Nothing. That is, not until you add an IBOutlet in whatever class
>> you want to connect to that instance. Say "AppController" has an
>> outlet called "thingController". You can then connect the
>> AppController's someThingController outlet to the "Some Thing
>> Controller" instance. Now, anywhere within your AppController class,
>> you can send messages to the "Some Thing Controller" instance by its
>> shiny new name:






Cocoa mail archive

