• 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
Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED] createDirectoryAtPath anomaly between system versions?


  • Subject: Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
  • From: Antonio Nunes <email@hidden>
  • Date: Fri, 7 Jul 2006 11:35:47 +0100

On 5 Jul 2006, at 10:47, Antonio Nunes wrote:

Is anybody aware of a change/bug-fix somewhere between 10.4.3 and 10.4.7 where creating a directory in applicationWillFinishLaunching works in 10.4.7 but not in 10.4.3?

Ok, I created a minimal test app, and the problem also showed up in 10.4.7, and it turns out I was mistaken about where exactly things were going wrong:


-Created a document based Cocoa app
-Created a class to be a delegate of the application object
-Connected the delegate in IB
-Added the following code to the delegate:

@implementation ANAppController

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
BOOL isDir, exists = NO, success = NO;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myAppDirectoryPath = nil;

NSArray *paths = NSSearchPathForDirectoriesInDomains (NSApplicationSupportDirectory, NSLocalDomainMask, YES);

if ([paths count] > 0) {
myAppDirectoryPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"MySupportFolderTestApp"];
exists = [fileManager fileExistsAtPath:myAppDirectoryPath isDirectory:&isDir];


if (!isDir) {
success = [fileManager createDirectoryAtPath:myAppDirectoryPath attributes:nil];
if (!success) {
[...]
}
} // if (!isDir)
} else {
[...]
} // if ([paths count] > 0)
}


@end

-Run the code in debug configuration and it works. Run it in release configuration and createDirectoryAtPath is never reached, which explains why the directory isn't created.

-Changing

		if  (!isDir) {
to
		if (!exists || !isDir) {

(which is conceptually more correct anyway) fixes this to work in release configuration builds too.

But I don't see why the former code would work in one configuration and not in another. Does anybody have any ideas? Why would the local variable isDir behave differently in the different build configurations? Should I file this as a bug with Apple?

Kind regards,
António

-----------------------------------------
Accepting others as they are
brings a wonderful freedom
to your own mind.

--The Peace Formula
-----------------------------------------




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
      • From: Nir Soffer <email@hidden>
References: 
 >createDirectoryAtPath anomaly between system versions? (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Fwd: Bindings Bug?
  • Next by Date: NSTableView - how to select text when editing a column?
  • Previous by thread: createDirectoryAtPath anomaly between system versions?
  • Next by thread: Re: [SOLVED] createDirectoryAtPath anomaly between system versions?
  • Index(es):
    • Date
    • Thread