Re: iPhone: NSFileManager/NSDirectoryEnumerator Crash?
Re: iPhone: NSFileManager/NSDirectoryEnumerator Crash?
- Subject: Re: iPhone: NSFileManager/NSDirectoryEnumerator Crash?
- From: Peter Lübke <email@hidden>
- Date: Fri, 11 Mar 2011 13:14:09 +0100
What about your "files" collection? Are you sure it is still valid
AND mutable on the second invocation?
Peter
NSString* directory = nil;
NSFileManager* fileManager = nil;
NSDirectoryEnumerator* walker = nil
directory = [NSHomeDirectory()
stringByAppendingPathComponent:@"Documents"];
if(directory == nil)
/* handle error and exit */
// fileManager = [NSFileManager defaultManager];
fileManager = [[NSFileManager alloc] init];
if(fileManager == nil)
/* handle error and exit */
walker = [fileManager enumeratorAtPath:directory];
if(walker == nil)
/* handle error and exit */
NSString* file = nil;
while((file = [walker nextObject]) != nil)
{
BOOL isDirectory = YES;
if([fileManager fileExistsAtPath:file
isDirectory:&isDirectory] && !isDirectory)
[files addObject:file];
}
...
[fileManager release];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden