• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOperation Issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOperation Issues


  • Subject: Re: NSOperation Issues
  • From: Varun Chandramohan <email@hidden>
  • Date: Mon, 21 Apr 2014 22:47:08 +0000
  • Thread-topic: NSOperation Issues

Hi Ken,

Sorry for opening up old thread. I noticed that the code I shared earlier
has stopped working in my app.

 QCCAESPadCryptor *  op;
    NSString *licenseKey = nil;
    NSOperationQueue *queue;
    op = [[QCCAESPadCryptor alloc] initToDecryptInputData:[NSData
dataWithBytes:cyphertext_dat length:sizeof(cyphertext_dat)]
                                                  keyData:[NSData
dataWithBytes:key_dat length:sizeof(key_dat)]
          ];
    op.ivData = [NSData dataWithBytes:iv_dat length:sizeof(iv_dat)];
    queue = [[NSOperationQueue alloc] init];
    [queue addOperation:op];
    [queue waitUntilAllOperationsAreFinished];


The thread was created to ask about this behaviour in daemon. However this
was working fine on my app for a while and now stopped working. I am not
even sure why its not working.
After [queue waitUntilAllOperationsAreFinished];

if (op.outputData != nil) {
        authString = [[[NSString alloc] initWithData:op.outputData
encoding:NSUTF8StringEncoding] autorelease];
    }

op.outputData is nil. This was not the case before. I don’t know how to
debug this. During the last discussion there was discussion about
mainThread. So I even tried a little experiment



- (void) runOp:(id) obj
{
    QCCAESPadCryptor *  op = obj;
    [queue addOperation:op];
    [queue waitUntilAllOperationsAreFinished];
}



[self performSelectorOnMainThread:@selector(runOp:) withObject:op
waitUntilDone:YES];


Neither did this work. Any suggestions?

Regards,
Varun

On 4/04/2014 11:16 am, "Ken Thomases" <email@hidden> wrote:

>On Apr 3, 2014, at 7:02 PM, Varun Chandramohan wrote:
>
>> On 4/04/2014 10:47 am, "Jerry Krinock" <email@hidden> wrote:
>>
>>> On 2014 Apr 03, at 16:11, Varun Chandramohan
>>> <email@hidden> wrote:
>>>
>>>> when I port the same code to be used as a user daemon, I noticed that
>>>> NSOperationQueue fails.
>>>
>>> I¹d suspect a run loop issue.  For example, maybe your daemon is
>>>exitting
>>> before the operation begins.
>>
>> Oh you mean, the runloop has not been initialised and the daemon is
>> exiting before that?
>> That could be the cause. Thanks I will investigate.
>
>If the code that was shown was running on the main thread, then the
>process should not have exited.  The code called [queue
>waitUntilAllOperationsAreFinished].
>
>In general, operation queues don't rely on the run loop.
>
>It is correct that if the code shown was in a background thread and
>nothing was keeping the main thread from exiting, then the process will
>be terminated, likely before the operation finished (or maybe even
>started) executing.  Parking the main thread in a loop running its run
>loop, assuming the run loop has at least one input source, is one way of
>preventing the main thread from exiting.  But that's the only tenuous
>relationship between run loops and operation queues.
>
>Regards,
>Ken
>


_______________________________________________

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


  • Follow-Ups:
    • Re: NSOperation Issues
      • From: Ken Thomases <email@hidden>
References: 
 >NSOperation Issues (From: Varun Chandramohan <email@hidden>)
 >Re: NSOperation Issues (From: Jerry Krinock <email@hidden>)
 >Re: NSOperation Issues (From: Varun Chandramohan <email@hidden>)
 >Re: NSOperation Issues (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Strange toolbar/view/resize cursor interaction
  • Next by Date: Re: ARC Retain Cycles
  • Previous by thread: Re: NSOperation Issues
  • Next by thread: Re: NSOperation Issues
  • Index(es):
    • Date
    • Thread