ios - Make NSOperationQueue synchronous -
how can make nsoperationqueue synchronous? did tried subclassing nsoperation , setting "setmaxconcurrentoperationcount" 1. , adding dependencies on previous operations using "adddependency" method.
adding code:
if(!operationqueue) { operationqueue = [[myqueue alloc] init]; } [operationqueue setmaxconcurrentoperationcount:1]; uploadfileoperation *uploadfileoperation = [[uploadfileoperation alloc] initwithobject:someobject]; [operationqueue addoperation:uploadfileoperation];
now when log upload progress 2 files shows both files uploading @ same time. this: file1 - 17.647026% uploaded file1 - 18.352907% uploaded file2 - 0.870381% uploaded file2 - 1.740762% uploaded file2 - 2.611142% uploaded file2 - 3.481523% uploaded file1 - 19.058788% uploaded
edit 2: how implemented nsoperation main method:
- (void)main { @autoreleasepool { if(self.iscancelled) { return; } [[[networkmanager alloc] init] uploadfiletoamazon:someurl withrequesttype:networkrequesttype withcompletion:^(networkrequesttype _networkrequesttype, id response, nserror *error) { nslog(@"response: %@", response); nslog(@"error: %@", error); if(uploadfiledelegate && [uploadfiledelegate respondstoselector:@selector(fileuploaded:)]) { [uploadclipdelegate fileuploaded:response]; } }]; } }
i'm using "afamazons3manager" uploading files in "uploadfiletoamazon".
Comments
Post a Comment