Re: Two arrays sharing the same adress space.
Re: Two arrays sharing the same adress space.
- Subject: Re: Two arrays sharing the same adress space.
- From: "Stephen J. Butler" <email@hidden>
- Date: Mon, 17 Nov 2008 03:32:54 -0600
On Mon, Nov 17, 2008 at 12:02 AM, Sandro Noel <email@hidden> wrote:
> NSFileManager *fileManager;
> fileManager = [NSFileManager defaultManager];
> if ( [fileManager fileExistsAtPath:[[self
> applicationSupportFolder] stringByAppendingPathComponent:@"Bonjour
> Mounter.plist"] isDirectory:NULL] ) {
> mounts = [[NSMutableArray alloc]
> initWithContentsOfFile:[[self applicationSupportFolder]
> stringByAppendingPathComponent:@"Bonjour Mounter.plist"]];
>
> }
> else{
> mounts = [[NSMutableArray alloc] init];
> }
I don't think this is the most robust solution. What happens if the
file exists, but isn't readable by your user? What if the file is
corrupt? mounts will end up nil . The better solution is:
mounts = [[NSMutableArray alloc]
initWithContentsOfFile:[[self applicationSupportFolder]
stringByAppendingPathComponent:@"Bonjour Mounter.plist"]];
if (mounts == nil)
mounts = [[NSMutableArray alloc] init];
_______________________________________________
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