Object(s) instantiated multiple times issue
Object(s) instantiated multiple times issue
- Subject: Object(s) instantiated multiple times issue
- From: gnat <email@hidden>
- Date: Tue, 7 Feb 2006 12:00:22 -0500
Hello,
I'm still rather new to Cocoa and GUI design, so please forgive the
ignorance if I show any. I have checked various places online (as
well as this lists archives), but i'm not even sure how to term what
I am trying to do or the issue I have found. Any input would be most
appreciated.
What I have:
I have a single NIB for my application.
To consolidate my code, I have multiple objects instantiated in my
NIB to group various functions together rather than one massive object.
What I want:
There are a few cases where these objects will need to share
"global" information (framework objects, generic information, etc..).
What I did:
I added an additional object to the NIB to contain this "global"
information and sends itself out to the others via a notification
during it's -awakeFromNib call.
What i'm seeing:
The "global" object works exactly as I expect. But I am seeing the
other objects apparently receive the notification multiple times. In
running it in debug, what I found was that self had a different
memory address each time the notification was received. Furthermore I
was getting a number of receptions equal to the number of outlets for
the object plus one (i'm guessing the object itself).
My questions:
1) I know that using the notifications isn't the best answer to solve
my sharing of information issue. What is the proper Cocoa way to do so?
2) Should my objects really be getting initialized that many times
(my notification listener is setup from the init method)?
3) How do I know which is the correct object to be working from in
this "multi-init" state? (i.e. in one case I am firing off a timer in
the -awakeFromNib of one object and found that I actually have 10 of
them running :/)
Thanks,
-dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden