// // 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