Re: Pref Panes and Instance Variables?
Re: Pref Panes and Instance Variables?
- Subject: Re: Pref Panes and Instance Variables?
- From: Doug Brown <email@hidden>
- Date: Sat, 12 Jan 2002 23:30:57 -0800
Hi Josh,
I don't have much experience with instance variables, but I do notice
one thing - you're not retaining the array that you're initializing, so
it basically gets thrown away at the end of the event loop. Unless
there's something special with preference panels, it should be:
theAppList = [[NSMutableArray array] retain];
I'm not sure about the CFString one - I have no experience with it.
HTH (I think),
Doug
Hello list,
I am having trouble with instance variables in my PrefPane.
I declare my variables in the header of my Principal Class like this:
@private
NSMutableArray *theAppList;
CFStringRef appID;
Then initialize them in initWithBundle like this:
- (id)initWithBundle:(NSBundle *)bundle
{
if ( ( self = [super initWithBundle:bundle] ) != nil )
{
appID = CFSTR("myPrefPaneBundleIdentifier");
theAppList = [NSMutableArray array];
}
return self;
}
Which is how Apple explains it in their PrefPane docs.
So far everything is OK.
I then fill my instance variable theAppList in mainViewDidLoad. This
too works fine but when I return out of this method all my variables are
killed. I set up a button which triggers a dump of these variables via
NSLog which confirm they are NULL or empty.
I can't imagine that this is a limitation to the PrefPane framework so
would someone kindly let me know what I am doing wrong?
Thanks!
M