CFPreferences and init.
CFPreferences and init.
- Subject: CFPreferences and init.
- From: Adam Penny <email@hidden>
- Date: Sun, 26 Oct 2008 00:11:35 +0200
Hi there,
It's been a few days, actually been able to make some progress on my
own for a change!
I've set up my initWithBundle method like this:
- (id)initWithBundle:(NSBundle *)bundle
{
if (![super initWithBundle:bundle]) return nil;
appID = CFSTR("uk.co.pennynet.Wopol");
servers= (NSMutableArray *)
CFPreferencesCopyAppValue( CFSTR("servers"), appID);
printers= (NSMutableArray *)
CFPreferencesCopyAppValue( CFSTR("printers"), appID);
broadcastIP= @"255.255.255.255";
return self;
}
Happily, it's getting my preferences as expected and the bindings are
filling them in in my table.
However, I was a bit concerned because if it can't find the servers or
printers keys in the plist then my NSMutableArray servers and printers
won't be allocated and initialized and it'll knacker everything else up.
I was thinking of doing something like this:
servers=[[NSMutableArray alloc]init];
if ('servers' key is in the plist and it's an array)
{
NSArray *serversInPlist=(NSArray *)
CFPreferencesCopyAppValue( CFSTR("servers"), appID);
[servers addObjectsFromArray: serversInPlist];
[serversInPlist release];
}
My question is how do I do the checks for the if clause?
Thanks,
Adam
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden