Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Raglan T Tiger
> On Oct 22, 2016, at 3:26 PM, Jens Alfke > wrote: > > specifically with handling dates what, y2k ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the li

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
> On 22 Oct 2016, at 23:26, Jens Alfke wrote: > > >> On Oct 22, 2016, at 2:21 PM, Jean Suisse > > wrote: >> >> I don’t know if it’s so irrelevant, because in the backtrace the swift code >> calls -[NSURLDirectoryEnumerator nextObject]. Maybe the ObjC code doesn’t.

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jens Alfke
> On Oct 22, 2016, at 2:21 PM, Jean Suisse wrote: > > I don’t know if it’s so irrelevant, because in the backtrace the swift code > calls -[NSURLDirectoryEnumerator nextObject]. Maybe the ObjC code doesn’t. > Hence my question. Obj-C for…in loops use NSFastEnumeration, which is equivalent to

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
> On 22 Oct 2016, at 23:15, Jens Alfke wrote: > > >> On Oct 22, 2016, at 12:11 PM, Jean Suisse > > wrote: >> >> To refine, what difference is there between ObjC’s >> for (NSURL* file in enumerator) >> and swift’s >> while let file = enumerator?.nextObjec

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jens Alfke
> On Oct 22, 2016, at 12:11 PM, Jean Suisse wrote: > > To refine, what difference is there between ObjC’s > for (NSURL* file in enumerator) > and swift’s > while let file = enumerator?.nextObject() as? URL That’s irrelevant. Look at the backtrace of the crash — the problem has to d

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Charles Srstka
> On Oct 22, 2016, at 2:42 PM, Jean Suisse wrote: > >> >> On 22 Oct 2016, at 21:24, Quincey Morris >> > > wrote: >> >> On Oct 22, 2016, at 11:42 , Jean Suisse > >

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
> On 22 Oct 2016, at 21:24, Quincey Morris > wrote: > > On Oct 22, 2016, at 11:42 , Jean Suisse > 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 u

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Quincey Morris
On Oct 22, 2016, at 11:42 , Jean Suisse 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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
I forgot the code: NSURL* directoryURL = [NSURL URLWithString:@"/.DocumentRevisions-V100/"]; NSFileManager* manager = [NSFileManager defaultManager]; NSArray* keys = @[NSURLNameKey, NSURLIsDirectoryKey]; NSDirectoryEnumerator* enumerator = [manager enumeratorAtUR

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Jens, The code below doesn’t crash. To refine, what difference is there between ObjC’s for (NSURL* file in enumerator) and swift’s while let file = enumerator?.nextObject() as? URL ? Jean > On 22 Oct 2016, at 20:55, Jens Alfke wrote: > > >> On Oct 22, 2016, at 11:42 AM,

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jens Alfke
> On Oct 22, 2016, at 11:42 AM, Jean Suisse wrote: > > To add a little more information: it happens when encountering any directory > that the user can’t read. > My app should get an access denied error (the enumerator should be nil for > instance). It shouldn’t crash. Try writing the same co

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
To add a little more information: it happens when encountering any directory that the user can’t read. My app should get an access denied error (the enumerator should be nil for instance). It shouldn’t crash. > On 22 Oct 2016, at 20:37, Jean Suisse wrote: > > Well, I was afraid of that. > Un

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Well, I was afraid of that. Unfortunately, below is the smallest sample of code possible… still crashes. Looks like I may have to check the directory rights before even attempting to enumerate it. Expected result in the present case is: “the while loop doesn’t run because the directory isn’t ac

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jens Alfke
Smells like an OS bug, or a bug in the ObjC-to-Swift bindings. Try to build a minimal test to reproduce it, i.e. narrow down which of the URLResourceKeys triggers the crash, and which specific file being returned by the enumerator. Then see what if anything is unusual about that file. Then proba

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Dear Quincey, Thank you for your reply. I have posted the code including the line below. It got deleted by mistake. 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.

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Quincey Morris
On Oct 22, 2016, at 10:43 , Jean Suisse wrote: > > while let file = enumerator?.nextObject() as? URL // > EXC_BAD_INSTRUCTION HERE You left out the line that defines “enumerator”. Incidentally, you have this: > let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V1

EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Dear All, Running the code below, I get EXC_BAD_INSTRUCTION error. My questions are: 1. Why ? 2. How can I prevent it ? Best regards, Jean CODE let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V100/") let manager = FileManager.default let k