Функция AppwillTerminate вызывается при нажатии nsalert - PullRequest
0 голосов
/ 26 июня 2019

Я работаю над техникой передачи файлов. В одном сценарии мы проверяем выходы файла / не показываем одно предупреждение. Если я нажал на предупреждение, кнопка «Да» или «Нет» автоматически перейдет к методу applicationWillTerminate.

Заранее спасибо!

-(void)sendFile {
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
     [self EnumerateAndFiles:filesList];
    });
 }


-(void)EnumerateAndFiles:filesList {
    @synchronized(self){
      for (NSString *path in subArray) {
          if (path exits) {
              [self shouldOverrideFile: path];
          }
       }
    }
 }


-(BOOL)shouldOverrideFile:(NSString*)filepath {
    @synchronized(self){
        __block NSInteger result=0;
        dispatch_sync(dispatch_get_main_queue(), ^{
            NSLog(@"ShouldOverrideForExistingFilePath 1");
            NSAlert *alert = [[NSAlert alloc] init];
            [alert addButtonWithTitle:@"Yes"];
            [alert addButtonWithTitle:@"No"];
            [alert setMessageText:@"Copy File"];
            [alert setInformativeText:[NSString 
         stringWithFormat:@"There is already a file with same name 
    [%@] in this location. Do you want to override it?",filepath]];
            [alert setAlertStyle:NSWarningAlertStyle];
            result = [alert runModal];

        });

        if ( result == NSAlertFirstButtonReturn ) {
           return YES;
        }
        else {
            return NO;
        }
     }
   }
...