refactor: Improve style and code for log controller
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// EQNLogViewController.h
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Luca Beretta on 01/12/18.
|
||||
// Copyright © 2018 Luca Beretta. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface EQNLogViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// EQNLogViewController.m
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Luca Beretta on 01/12/18.
|
||||
// Copyright © 2018 Luca Beretta. All rights reserved.
|
||||
//
|
||||
|
||||
#import "EQNLogViewController.h"
|
||||
#import "EQNManager.h"
|
||||
#import "EQNAccelerometroManager.h"
|
||||
#import "EQNUser.h"
|
||||
|
||||
@interface EQNLogViewController ()
|
||||
@property (weak, nonatomic) IBOutlet UITextView *logView;
|
||||
@property (nonatomic, strong) NSString *testo;
|
||||
@end
|
||||
|
||||
@implementation EQNLogViewController
|
||||
|
||||
#pragma mark - View Lifecycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aggiornaLog:) name:EQNDebugLogWillUpdateNotification 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;
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)chiudi:(id)sender
|
||||
{
|
||||
[[EQNManager defaultManager] stopManager];
|
||||
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Notifications
|
||||
|
||||
- (void)aggiornaLog:(NSNotification *)notificaton
|
||||
{
|
||||
NSDictionary *messaggio = notificaton.userInfo;
|
||||
NSString *messagioString = messaggio[@"messaggio"];
|
||||
NSString *mes = self.logView.text;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.logView.text = [NSString stringWithFormat:@"%@\n%@", mes, messagioString];
|
||||
});
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user