Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/
Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/
- Subject: Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/
- From: Quincey Morris <email@hidden>
- Date: Sat, 22 Oct 2016 12:24:41 -0700
- Feedback-id: 167118m:167118agrif8a:167118sO2yHp9M-p:SMTPCORP
On Oct 22, 2016, at 11:42 , Jean Suisse <email@hidden> 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 (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