• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CFPreferences and init.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: CFPreferences and init.
      • From: "Kyle Sluder" <email@hidden>
  • Prev by Date: Re: NSPersistentDocument: "Settings" (DepartmentsAndEmployees)
  • Next by Date: Re: CFPreferences and init.
  • Previous by thread: Re: How to exit a thread help...
  • Next by thread: Re: CFPreferences and init.
  • Index(es):
    • Date
    • Thread