Re: Newbie Q - Variables not being retained in class
Re: Newbie Q - Variables not being retained in class
- Subject: Re: Newbie Q - Variables not being retained in class
- From: Aaron Wallis <email@hidden>
- Date: Sat, 10 Sep 2005 13:51:35 +1000
Hi Daniel,
your on the ball with this one, I have worked out where the code is
going wrong, but I have NO idea on how to get about it [without
causing problems later on]
basically, the source that I posted in the previous email belongs to
a class file which [ now that I have worked it out] is leading a
double life.
One life as the File Owner of my preference.nib and another as a
object in the core off my app [ loaded as mpPreference *mypreference
= [[ mpPreference alloc ] initPreferences ]; ]
So, whats actually happening is, the object 'life' of my class is
processing and loading the preferences, and the file owner 'life' is
requesting the data - however [unless im miss-understanding the code]
the two instances are independent, and do not share the same
information, so thats why when I try to set a NSTextField with the
value of a preference, it returns nil, cause the custom init
functions haven't been called....
Man, what a nightmare for a newbie to work out...
anyway, now that I understand what the hell is going on, does anyone
have any pointers on how to fix this? my heads already hurting as it
is...
Many thanks for your help !!
You guys are making Cocoa even easier to learn ! [ Many thanks =D ]
_Az.
On 10/09/2005, at 1:00 PM, Jack wrote:
which
means that defaultPrefs is finally released and dealloc'd.
RegisterDefaults: retains the values inside the dictionary as they
are added
to the NSRegistrationDomain.
The code is fine. What might be happening is your confusing what
registerDefaults: does. It creates a new domain lower than your
com.application domain. The .plist file that you are seeing in your
library
is actually empty. Starting up your app an second time and calling
savePrefs: without first calling setupPreferences: will give you
nil. Not
only because your instance variable myPrefs is not initialized
(which you
shouldn't use as was pointed out earlier) but also because you need to
register the defaults every single time you start the app. The
defaults are
just that a backup value if no value exists in your regular
com.application
domain.
Regards,
Jack
www.Bruji.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40yahoo.com.au
This email sent to email@hidden
Send instant messages to your online friends http://au.messenger.yahoo.com
_______________________________________________
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