On 14 Aug 2015, at 8:47 PM, Rick Mann wrote:
>
> So, adding lazy lets it work with the closure (makes self available to the
> closure):
>
> lazy varbackgroundSession : NSURLSession=
> {
...
>
> I really wish you could do lazy let foo = I don't see why the l
So, adding lazy lets it work with the closure (makes self available to the
closure):
lazy varbackgroundSession : NSURLSession=
{
let config =
NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier("com.matterport.StandaloneShowcase.ModelFetchCo
On Aug 14, 2015, at 17:26 , Jens Alfke wrote:
>
> (Either way, it would still make sense for ‘self’ to be available.)
Yes and no. Because it’s an ivar, the ivar’s value is associated with an
instance rather than a class, but:
— It’s being initialized by an arbitrary closure. There’s no particu
> On Aug 14, 2015, at 4:32 PM, Quincey Morris
> wrote:
>
> No, there’s no instance here. “Enclosing” doesn’t really make any sense.
It’s in the declaration of the ivar, I mean ‘stored property’,
backgroundSession, so there is an instance.
But I just realized that Rick forgot the “lazy” keywo
On Aug 14, 2015, at 15:44 , Rick Mann wrote:
>
> What is the type of "self" in the initializer closure,
It’s the class object itself, not an instance.
> and is there a way to refer to the enclosing class instance?
No, there’s no instance here. “Enclosing” doesn’t really make any sense.
> On Aug 14, 2015, at 4:24 PM, Rick Mann wrote:
>
> I really would've hoped that since the closure is defined within the scope of
> an instance of the class, that it would have a self made available to it.
> I've seen similar code that used "[unowned self] in" to use a weak reference.
Well,
> On Aug 14, 2015, at 16:07 , Jens Alfke wrote:
>
>
>> On Aug 14, 2015, at 3:44 PM, Rick Mann wrote:
>>
>> What is the type of "self" in the initializer closure,
>
> Wow, I didn’t even think you could use ‘self’ in such a context, since you’re
> not inside a method, just a closure. But it l
> On Aug 14, 2015, at 3:44 PM, Rick Mann wrote:
>
> What is the type of "self" in the initializer closure,
Wow, I didn’t even think you could use ‘self’ in such a context, since you’re
not inside a method, just a closure. But it looks as though ‘self’ has type
'MyDelegate -> () -> MyDelegate’
I'm having a hard time with this code:
import Foundation
class MyDelegate : NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate,
NSURLSessionDownloadDelegate
{
func URLSession(session: NSURLSession, downloadTask:
NSURLSessionDownloadTask, didFinishDownloadingTo