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: Daniel Jalkut <email@hidden>
- Date: Fri, 09 Sep 2005 12:48:28 -0400
In Objective-C, variables don't just "turn to nil" unless somebody
sets them that way. Maybe there's some other code you're not showing
us that could be setting it to nil?
Anyway, you should technically be "retain"ing and "release"ing the
standard user defaults, if you want to hold onto it in your class.
Since it's an app-global singleton, it's not liable to actually go
away, but you want to get in the habit of retaining things for which
you're relying on them sticking around. Release them in your
object's dealloc method.
It's also possible that your entire class has been deallocated, and
whatever is now in its place happens to be using that offset for
"zero". What happens if you add a call:
NSLog(@"My retain count is %d", [self retainCount]);
To you savePreferences method?
It sounds like you probably need to read up on the Cocoa memory
management policies, so you'll be over all comfortable and confident
enough to approach Cocoa programming without making too many hard-to-
find mistakes.
Daniel
On Sep 9, 2005, at 11:57 AM, Aaron Wallis wrote:
Now, when I call setupPreferences the defaults are created [I can
see the pref file in my library], however, when I call
savePreferences, myPrefs is equal to nil...
Now, as I said, im new to cocoa, but I take it this has to do with
memory management?.... maybe? or do I have a syntax error? maybe???
_______________________________________________
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