Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
iOS project that reproduces NSDirectoryEnumerator problem
Objective-C C
tree: bde3e5dec3

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Classes
DirectoryEnumerator.xcodeproj
.gitattributes
.gitignore
DirectoryEnumerator-Info.plist
DirectoryEnumeratorViewController.xib
DirectoryEnumerator_Prefix.pch
MainWindow.xib
README.markdown
main.m

README.markdown

I'm attempting to use an NSDirectoryEnumerator created via NSFileManager's enumeratorAtURL method. The enumerator returned fails to enumerate any paths and crashes the app when it is released. I've reduced the code the following:

- (void)enumerateResources {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSDirectoryEnumerator *enumerator  = [fileManager enumeratorAtURL:[[NSBundle mainBundle] resourceURL] 
                                           includingPropertiesForKeys:NULL 
                                                              options:NSDirectoryEnumerationSkipsSubdirectoryDescendants
                                                         errorHandler:nil];
    NSAssert(enumerator != nil, @"enumerator is nil");

    id pathname;
    for(pathname in enumerator) {
        NSLog(@"%@", pathname);
    }
}

When that method is run I get the following backtrace and the message, "GDB: Interrupted":

#0  0x022a3b00 in CFRelease ()
#1  0x000aef94 in -[NSURLDirectoryEnumerator dealloc] ()
#2  0x022a3acc in CFRelease ()
#3  0x022c8bcd in _CFAutoreleasePoolPop ()
#4  0x0000a99f in -[NSAutoreleasePool release] ()
#5  0x002baf84 in _UIApplicationHandleEvent ()
#6  0x02bf2afa in PurpleEventCallback ()
#7  0x0236ddc4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#8  0x022ce737 in __CFRunLoopDoSource1 ()
#9  0x022cb9c3 in __CFRunLoopRun ()
#10 0x022cb280 in CFRunLoopRunSpecific ()
#11 0x022cb1a1 in CFRunLoopRunInMode ()
#12 0x002b3226 in -[UIApplication _run] ()
#13 0x002beb58 in UIApplicationMain ()
#14 0x00001fb4 in main (argc=1, argv=0xbfffef98) at /Users/wmoore/Source/DirectoryEnumerator/main.m:14

This project reproduces the problem.

If anyone has any suggestions they would be most welcome, otherwise I will submit a ticket to (open)radar. Its worth noting that using enumeratorAtPath works fine.

Something went wrong with that request. Please try again.