Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 17:51 , Greg Parker wrote: > > The power of `case` outside `switch` was increased at some point. It's likely > that the documentation has not caught up. You should file a bug report. I did. Thanks for the confirmation, though! -- Rick Mann rm...@latencyzero.com __

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
> On Jul 7, 2015, at 5:30 PM, Rick Mann wrote: > > Thanks. I was looking at the Swift reference. The docs seem to be incorrect: > > https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Patterns.html#//apple_ref/swift/grammar/pattern > > "

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 17:30 , Roland King wrote: > > 1) If you’re sure it’s not nil, which for that particular case of an > enumerator from a filemanager I’d agree it’s not (can’t make one work in a > playground to test) then just force-unwrap it > 2) As concise as ‘for case let url as NSURL in

Re: Any way to combine for and if-let?

2015-07-07 Thread Roland King
> On 8 Jul 2015, at 08:26, Quincey Morris > wrote: > > On Jul 7, 2015, at 16:58 , Rick Mann wrote: >> >> Also, the enumerator is a NSDirectoryEnumerator. It returns AnyObject type, >> so wouldn't there have to be an NSURL cast in there somewhere? > > > Try: > >> for case let url as NSURL

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
Thanks. I was looking at the Swift reference. The docs seem to be incorrect: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Patterns.html#//apple_ref/swift/grammar/pattern "There are two type-casting patterns, the is pattern and the as

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 17:28 , Greg Parker wrote: > > for case let item as NSURL in Yes, but you can’t honestly tell me you’re proud of that syntax, can you? ;) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests o

Re: Any way to combine for and if-let?

2015-07-07 Thread Greg Parker
> On Jul 7, 2015, at 4:58 PM, Rick Mann wrote: > >> On Jul 7, 2015, at 16:52 , Quincey Morris >> wrote: >> >>> On Jul 7, 2015, at 16:42 , Rick Mann wrote: >>> >>> for item in enumerator! >> >> Like this: >> >>> for case let item? in enumerator! >> >> (Yes, it’s stupid.) > > Hmm. It does

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 16:58 , Rick Mann wrote: > > Also, the enumerator is a NSDirectoryEnumerator. It returns AnyObject type, > so wouldn't there have to be an NSURL cast in there somewhere? Try: > for case let url as NSURL in enumerator The way to figure these things out is to start with a sw

Re: Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
> On Jul 7, 2015, at 16:52 , Quincey Morris > wrote: > > On Jul 7, 2015, at 16:42 , Rick Mann wrote: >> >> for item in enumerator! > > Like this: > >> for case let item? in enumerator! > > (Yes, it’s stupid.) Hmm. It doesn't seem to like that: '?' pattern cannot match values of type 'Ele

Re: Any way to combine for and if-let?

2015-07-07 Thread Quincey Morris
On Jul 7, 2015, at 16:42 , Rick Mann wrote: > > for item in enumerator! Like this: > for case let item? in enumerator! (Yes, it’s stupid.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator co

Any way to combine for and if-let?

2015-07-07 Thread Rick Mann
Is there any way to combine the for and if-let into one line that gives me unwrapped NSURL objects to work on? I believe the enumerator (which came from NSFileManager) will only have valid NSURLs in it. for item in enumerator! { if let url = item as? NSURL { l