Re: NSURLConnection from inside -[NSManagedObjectContext performBlock:]?
Re: NSURLConnection from inside -[NSManagedObjectContext performBlock:]?
- Subject: Re: NSURLConnection from inside -[NSManagedObjectContext performBlock:]?
- From: Laurent Daudelin <email@hidden>
- Date: Mon, 18 Nov 2013 22:13:10 -0500
From a secondary thread, I use NSRunLoopCommonModes and it seems to run fine.
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software email@hidden
On Nov 18, 2013, at 21:46, Rick Mann <email@hidden> wrote:
> It does have a run loop, but the current mode is nil.
>
> (lldb) po rl
> <CFRunLoop 0xb2b0ff0 [0x3dd5ec8]>{wakeup port = 0x7213, stopped = false, ignoreWakeUps = true,
> current mode = (none),
> common modes = <CFBasicHash 0xb2a5560 [0x3dd5ec8]>{type = mutable set, count = 1,
> entries =>
> 1 : <CFString 0x3dd20a4 [0x3dd5ec8]>{contents = "kCFRunLoopDefaultMode"}
> }
> ,
> common mode items = (null),
> modes = <CFBasicHash 0xb2a59b0 [0x3dd5ec8]>{type = mutable set, count = 1,
> entries =>
> 1 : <CFRunLoopMode 0xb2da970 [0x3dd5ec8]>{name = kCFRunLoopDefaultMode, port set = 0x7313, timer port = 0x7403,
> sources0 = (null),
> sources1 = (null),
> observers = (null),
> timers = (null),
> currently 406521903 (1771484083894466) / soft deadline in: 1.84449726e+10 sec (@ 0) / hard deadline in: 1.84449726e+10 sec (@ 0)
> },
>
> }
> }
>
> I didn't try scheduleInRunLoop:forMode:, because I didn't know what to pass in for the mode.
>
>
> On Nov 18, 2013, at 18:41 , Laurent Daudelin <email@hidden> wrote:
>
>> Most likely it doesn’t have a runloop.
>>
>> Have you tried scheduleInRunLoop:forMode:?
>>
>> -Laurent.
>> --
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
>> Logiciels Nemesys Software email@hidden
>>
>> On Nov 18, 2013, at 21:29, Rick Mann <email@hidden> wrote:
>>
>>> I think I'm starting to understand what I'm doing wrong here…
>>>
>>> I seem to be having trouble calling making an NSURLConnection inside a call to -[NSManagedObjectContext performBlock:]. I can set it up, but my delegate never gets called back.
>>>
>>> I create the NSURLConnection with:
>>>
>>> conn = [[...] initWithRequest:req delegate: del startImmediately: NO];
>>>
>>> and then, after setting up a few things, I call
>>>
>>> [conn start];
>>>
>>> The docs say start will schedule the connection in the "default" modes. The MOC's run loop mode is nil. Is this why it's not getting called back? What's the right thing to do here?
>>>
>>> The nice thing about scheduling it on the MOC is that the callbacks happen in the MOC. But maybe -[NSMOC performBlock:] does more than just dispatch the block to the MOC's queue.
>>>
>>> I just went to see if I could use setDelegateQueue: on the connection, realizing two things: 1) It's an NSOperationQueue, not a dispatch queue, and 2) I can't get at either for an NSMOC, so it looks like I really can't start a connection from inside -[NSMOC performBlock:].
>>>
>>> Am I right about this?
>>>
>>
>
>
> --
> Rick
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden