sharedQueue operationCount всегда идет вверх - PullRequest
0 голосов
/ 13 мая 2019

Я использую приведенный ниже код для добавления потока

static NSOperationQueue *sharedQueue = nil;
//..
sharedQueue = [[NSOperationQueue alloc] init];
//..

NSArray *a=[[NSArray alloc]initWithObjects:[@(tag) stringValue],server,filePath,userName,password,serverPath,[@(fileSize) stringValue], nil];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
        selector:@selector(newFtpOperation:) object:a ];
[sharedQueue addOperation:operation]; //add thread
//
//..

-(void)newFtpOperation:(NSArray*)aArray{

    NMSSHSession *session  = [NMSSHSession connectToHost:server withUsername:userName];
    //do something

    [session disconnect];

    //the end of newFtpOption
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ftpDone" object:[@(tag) stringValue]];

}


- (void)ftpDone:(NSNotification *)obj;{


     //[sharedQueue operationCount] always goes up rather than goes down at the end of newFtpOperation
}

, но в конце потока [sharedQueue operationCount] всегда идет вверх, а не падает.

Я пытаюсь использовать

NSArray *ops=[sharedQueue operations];
[[ops objectAtIndex:[[obj object] integerValue]] cancel];

отмена NSOperation, но похоже, что количество элементов [sharedQueue операции] не изменяется

Ваш комментарий приветствуется

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...