67 lines
2.4 KiB
Objective-C
67 lines
2.4 KiB
Objective-C
//
|
|
// ViewController.m
|
|
// FMC Planner 2
|
|
//
|
|
// Created by Kilian Hofmann on 19.03.16.
|
|
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
|
//
|
|
|
|
#import "ViewController.h"
|
|
|
|
@implementation ViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
// Round corners
|
|
_backdropKeys.layer.cornerRadius = 5;
|
|
_backdropKeys.layer.masksToBounds = YES;
|
|
_backdropScreen.layer.cornerRadius = 5;
|
|
_backdropScreen.layer.masksToBounds = YES;
|
|
// Setup save system
|
|
_save = [[NSMutableDictionary alloc] init];
|
|
}
|
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
NSString *segueName = segue.identifier;
|
|
if ([segueName isEqualToString:@"keyboard"]) {
|
|
_keys = (ViewControllerKeyboard *)segue.destinationViewController;
|
|
_keys.main = self;
|
|
}
|
|
if ([segueName isEqualToString:@"screen"]) {
|
|
_screen = (ViewControllerScreen *)segue.destinationViewController;
|
|
_screen.main = self;
|
|
}
|
|
}
|
|
|
|
#warning TODO: check if file already exists -- load or replace
|
|
#warning TODO: else -> jump to file browsing for load/delete
|
|
- (void)saveToFile:(NSDictionary *)save {
|
|
if (!([_save valueForKey:@"MENU@LSKR1"] == nil ||
|
|
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(
|
|
NSDocumentDirectory, NSUserDomainMask, YES);
|
|
NSString *documentsPath = [paths objectAtIndex:0];
|
|
[_save writeToFile:[documentsPath
|
|
stringByAppendingString:
|
|
[NSString
|
|
stringWithFormat:
|
|
@"/%@",
|
|
[_save valueForKey:@"MENU@LSKR1"]]]
|
|
atomically:YES];
|
|
}
|
|
}
|
|
|
|
- (void)loadSave:(NSString *)file {
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
|
|
NSUserDomainMask, YES);
|
|
NSString *documentsPath = [paths objectAtIndex:0];
|
|
NSString *filePath = [documentsPath
|
|
stringByAppendingString:[NSString stringWithFormat:@"/%@", file]];
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
|
|
_save = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
|
|
}
|
|
}
|
|
|
|
@end
|