فهرست منبع

修改timer时间,将读取cache放在登录后

Pen Li 9 سال پیش
والد
کامیت
a61ff41200

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 4 - 2
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -80,6 +80,7 @@
 }
 -(void) viewWillAppear:(BOOL)animated
 {
+    [self start_urgency_timer];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
     
@@ -90,7 +91,7 @@
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
     }
 #endif
-    [self start_urgency_timer];
+    
 }
 -(void) viewWillDisappear:(BOOL)animated
 {
@@ -125,8 +126,9 @@
     
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     
-    [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:30 queue:nil repeats:YES action:^{
+    [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:10 queue:nil repeats:YES action:^{
         
+        NSLog(@"timer start....");
         [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
         [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
         [appDelegate.urgencyDic setValue:self.content_data_download forKey:[NSString stringWithFormat:@"%@_changed_data",self.class_name]];

+ 6 - 3
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -529,6 +529,8 @@ void UncaughtExceptionHandler(NSException *exception) {
 
 - (void)handleUrgencyFile {
     
+    [self readUrgencyCache];
+    
     NSLog(@"urgencyDic: %@",self.urgencyDic);
     if (self.urgencyDic.allKeys.count) {
         
@@ -677,7 +679,8 @@ void UncaughtExceptionHandler(NSException *exception) {
     NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
     NSString *urgencyFile = [cachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_urgency",self.user]];
 
-    [NSKeyedArchiver archiveRootObject:self.urgencyDic toFile:urgencyFile];
+//    [NSKeyedArchiver archiveRootObject:self.urgencyDic toFile:urgencyFile];
+    [self.urgencyDic writeToFile:urgencyFile atomically:NO];
 }
 
 - (void)readUrgencyCache {
@@ -688,7 +691,8 @@ void UncaughtExceptionHandler(NSException *exception) {
     
     if ([manager fileExistsAtPath:urgencyFile]) {
         
-        _urgencyDic = [NSKeyedUnarchiver unarchiveObjectWithFile:urgencyFile];
+//        _urgencyDic = [NSKeyedUnarchiver unarchiveObjectWithFile:urgencyFile];
+        _urgencyDic = [NSMutableDictionary dictionaryWithContentsOfFile:urgencyFile];
         [manager removeItemAtPath:urgencyFile error:nil];
         
     } else {
@@ -699,7 +703,6 @@ void UncaughtExceptionHandler(NSException *exception) {
 
 - (void)initialExceptionHandler {
     NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
-    [self readUrgencyCache];
 }
 
 - (void)becomeObserver {