NSFileManager miscount
NSFileManager miscount
- Subject: NSFileManager miscount
- From: John Stokes <email@hidden>
- Date: Tue, 11 Mar 2003 10:12:20 -0800
I have a strange problem. I'm new to this, so forgive my ignorance.
-First, I create a directory programmatically (in ~/Documents) and populate
it with some files.
-Then, I'm using an NSFileManager to load the file names in the directory
into an array...
directoryArray = [MyFileManager directoryContentsAtPath:userPath];
-I calculate the number of files in the directory by calling the "count"
method on the file name array
int totalGroups = [directoryArray count];
-then, I use a for loop to generate a button for each file in the directory.
for(counter=0;counter<=totalGroups;counter++) {
-Here's my problem: After creating the directory programmatically, if I have
3 files in the directory, "totalGroups" = 3. So far, so good.
BUT, if I access the directory using the Finder, and then re-run my program,
suddenly "totalGroups" = 4. This results in my program creating an extra,
blank button that doesn't do anything. I can duplicate this error by
dragging a file out of the directory my program created and then back in.
If I go back and delete my directory and allow the program to re-create it,
"totalGroups" goes back to 3.
Why? How do I get around this?
--
-John Stokes
Computer Psychiatrist (Director of Information Technology)
Church Resource Ministries
email@hidden
Three Pillars: Humility, Communication, Balance
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.