|
|
@@ -24,11 +24,16 @@
|
|
|
|
|
|
AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
|
|
|
|
-
|
|
|
- [appdelegate.uploadManager addObserver:self
|
|
|
- forKeyPath:@"arr_queue"
|
|
|
- options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
|
|
|
- context:@"arr_queue changed"];
|
|
|
+ // 如果ViewController创建在UploadManager初始化之前,那么KVO失效,界面刷新不正确而导致数组越界
|
|
|
+ if (appdelegate.uploadManager != nil) {
|
|
|
+ [appdelegate.uploadManager addObserver:self
|
|
|
+ forKeyPath:@"arr_queue"
|
|
|
+ options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
|
|
|
+ context:@"arr_queue changed"];
|
|
|
+ } else {
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadRefreshNotification:) name:UPLOAD_COUNT_CHANGE_NOTIFICATION object:nil];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
self.title = NSLocalizedString(@"Upload List", nil);
|
|
|
UIBarButtonItem *uploadListItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Clear", nil) style:UIBarButtonItemStylePlain target:self action:@selector(clearList)];
|
|
|
@@ -96,7 +101,9 @@
|
|
|
}
|
|
|
|
|
|
- (void)uploadRefreshNotification:(NSNotification *)notification {
|
|
|
- [self.uploadTableView reloadData];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [self.uploadTableView reloadData];
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
#pragma mark - TableView DataSource
|