我正在研究文件传输技术。在一种情况下,我们正在检查文件出口/不显示一个警报。如果按警报,则“是”或“否”按钮将自动转到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;
}
}
}