reload disk list after importing document

This commit is contained in:
Jesús A. Álvarez 2016-06-06 19:42:10 +02:00
parent f511efdb0b
commit 222a6d8d8f
3 changed files with 7 additions and 0 deletions

View File

@ -9,6 +9,8 @@
#import <UIKit/UIKit.h>
#import "EmulatorProtocol.h"
extern NSString *DocumentsChangedNotification;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;

View File

@ -13,6 +13,7 @@
static AppDelegate *sharedAppDelegate = nil;
static NSObject<Emulator> *sharedEmulator = nil;
NSString *DocumentsChangedNotification = @"documentsChanged";
@interface AppDelegate () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning>
@ -286,6 +287,8 @@ static NSObject<Emulator> *sharedEmulator = nil;
if (error) {
[self showAlertWithTitle:fileName message:error.localizedFailureReason];
} else {
NSDictionary *userInfo = @{@"path": destinationPath};
[[NSNotificationCenter defaultCenter] postNotificationName:DocumentsChangedNotification object:self userInfo:userInfo];
[self showAlertWithTitle:@"File Import" message:[NSString stringWithFormat:@"%@ imported to Documents", destinationPath.lastPathComponent]];
}
}

View File

@ -64,6 +64,7 @@
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].insertDiskNotification object:nil];
[nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil];
[nc addObserver:self selector:@selector(reloadData:) name:DocumentsChangedNotification object:nil];
}
- (void)viewDidDisappear:(BOOL)animated {
@ -71,6 +72,7 @@
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self name:[AppDelegate sharedEmulator].insertDiskNotification object:nil];
[nc removeObserver:self name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil];
[nc removeObserver:self name:DocumentsChangedNotification object:nil];
}
- (void)loadDirectoryContents {