On Mon, Nov 17, 2008 at 12:02 AM, Sandro Noel <[EMAIL PROTECTED]> 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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]