Re: Not skipping Descendents
Re: Not skipping Descendents
- Subject: Re: Not skipping Descendents
- From: Jeremy Dronfield <email@hidden>
- Date: Wed, 5 May 2004 19:56:15 +0100
-skipDescendents "causes the receiver to skip recursion into the most
recently obtained subdirectory". It isn't a means of turning
NSDirectoryEnumerator into NSFileManager -directoryContentsAtPath. You
might use it like this:
while (file = [enumerator nextObject])
{
BOOL isDir;
if ([[NSFileManager defaultManager] fileExistsAtPath:file
isDirectory:&isDir] && isDir)
[enumerator skipDescendents];
[usersArray addObject:file];
NSLog(@"%@",file);
}
On 5 May 2004, at 7:02 pm, email@hidden wrote:
Greetings all i'm using the directory enumerator to populate a users
menu but won't skip descendents am i doing something wrong?
- (void)populateUsersMenu;
{
NSString *file;
NSDirectoryEnumerator *enumerator = [[NSFileManager
defaultManager]
enumeratorAtPath:@"/Users"];
[enumerator skipDescendents];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
while (file = [enumerator nextObject])
{
[usersArray addObject:file];
NSLog(@"%@",file);
}
[pool release];
NSMenu *usersMenu = [[NSMenu alloc] initWithTitle:@"users"];
NSEnumerator *e = [usersArray objectEnumerator];
id object;
while(object = [e nextObject])
{
[usersMenu insertItemWithTitle:object action:nil
keyEquivalent:@"" atIndex:0];
}
[usersButton setMenu:usersMenu];
[usersMenu release];
}
_______________________________________________
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.
_______________________________________________
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.