Files
eqn.ios/Sources/Earthquake Network/ViewController/LogViewController.m
T
Andrea Busi a9f16bca4a refactor: Reorganise code related to background monitoring
- Move to Models folder
- Improve code and nullability notation
- Rename class with typo in name
2020-12-07 09:46:43 +01:00

77 lines
2.2 KiB
Objective-C

//
// LogViewController.m
// Earthquake Network
//
// Created by Luca Beretta on 01/12/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "LogViewController.h"
#import "EQNManager.h"
#import "EQNAccelerometroManager.h"
#import "EQNUser.h"
@interface LogViewController ()
@property (nonatomic, strong) IBOutlet UITextView *logView;
@property (nonatomic, strong) NSString *testo;
-(IBAction)chiudi:(id)sender;
@end
@implementation LogViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aggiornaLog:) name:@"AGGIORNA_LOG" object:nil];
[[EQNManager defaultManager] avviaManager];
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
self.testo = [NSString stringWithFormat:@" LOG ID UTENTE %@\n\nTOKEN FIREBASE:\n%@\n\n", [EQNUser defaultUser].user_ID, [EQNUser defaultUser].tokenUser];
self.logView.text = self.testo;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)chiudi:(id)sender{
[[EQNManager defaultManager] stopManager];
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)aggiornaLog:(NSNotification *)notificaton{
NSDictionary *messaggio = notificaton.userInfo;
NSString *messagioString = messaggio[@"messaggio"];
NSString *mes = self.logView.text;
// [mes stringByAppendingString:messagioString];
dispatch_async(dispatch_get_main_queue(), ^{
self.logView.text = [NSString stringWithFormat:@"%@\n%@", mes, messagioString];
});
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end