Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
hello guys,

i am trying to validate, if the certain folder in a path exist or not! i checked this code:
Code:
NSFileManager *filemgr
	BOOL s=[filemgr fileExistsAtPath:@"/Extra" ];
	
	if (s== NO) {
		NSLog(@"This path does not exist or its existence could not be determined!");
		
	}else {
		NSLog(@"path exist.");
	}

but eventhough /Extra is a valid path it return NO yet!
 
So, /Extra... Where exactly is that on your hard drive?

Because you're saying that it's located at the root of your hard drive.
 
You haven't initialised fileMgr. So it's nil. So any message sent to it will be a no-op. Any return value from the no-op will be binary zero. Which when interpreted as a BOOL is NO.

You can get a NSFileManager object with [NSFileManager defaultManager].
 
Ah yes, what jiminaus said as well. (I figured the method you used was a class method but nope! :))
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.