On Oct 22, 2016, at 11:42 , Jean Suisse <jean.li...@gmail.com> wrote:
> 
> My app should get an access denied error (the enumerator should be nil for 
> instance). It shouldn’t crash.

It can’t return nil, because that is used to signal the end of the enumeration. 
I agree it’s nasty if it crashes, though.

> Though it looks like I am trying to access "/.DocumentRevisions-V100/“, it is 
> not what I am trying to achieve. 
> 
> At some point my app needs to enumerate user-selected directories. The issue 
> is I get a crash when directories such as "/.DocumentRevisions-V100/“ are 
> present.
> I cannon reasonably maintain a list of “don’t enumerate” directories.

It’s still not quite clear what your real code is trying to do. If you were 
enumerating the *root* directory *shallowly* (.skipsSubdirectoryDescendants), 
and you hit this directory, you should *not* try to descend explicitly into 
this directory (or any directory whose name begins with a period, I suppose) as 
your sample code does. If you were doing a deep enumeration from the root 
directory, you wouldn’t be executing shallow enumeration code as in your sample 
code.

Can you use the .skipsHiddenFiles option for your real enumerator? That will 
skip files and directories whose name starts with a period.

> To refine, what difference is there between ObjC’s 
>       for (NSURL* file in enumerator)
> 
> and swift’s
> 
>       while let file = enumerator?.nextObject() as? URL
> ?

You’re comparing unlike things. Regardless of language, “for … in” and “while … 
nextObject” use different mechanisms for maintaining state between iterations. 
What does the Swift version of the “for … in” loop do?


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to