/SaveExample/SaveExampleMac/MacViewController.m
Objective C | 46 lines | 25 code | 14 blank | 7 comment | 0 complexity | 366076c151236b6db3c2d2f51957f33e MD5 | raw file
1// 2// MacViewController.m 3// SaveExample 4// 5// Created by Alexander Blunck on 18.03.12. 6// Copyright (c) 2012 Ablfx. All rights reserved. 7// 8 9#import "MacViewController.h" 10#import "ABSaveSystem.h" 11#import "Person.h" 12 13@implementation MacViewController 14 15-(IBAction)load:(id)sender { 16 NSLog(@"load..."); 17 18 ABSaveSystem *saveSystem = [ABSaveSystem saveSystem]; 19 saveSystem.superOS = ssMAC; 20 21 Person *loadedPerson = [NSKeyedUnarchiver unarchiveObjectWithData:[saveSystem loadDataForKey:@"person"]]; 22 NSString *formatedString = [NSString stringWithFormat:@"%@, %i", loadedPerson.name, loadedPerson.age]; 23 24 loadField.stringValue = formatedString; 25 26 [saveSystem release]; 27} 28 29-(IBAction)save:(id)sender { 30 NSLog(@"save..."); 31 32 ABSaveSystem *saveSystem = [ABSaveSystem saveSystem]; 33 saveSystem.superOS = ssMAC; 34 35 Person *newPerson = [Person new]; 36 newPerson.name = nameField.stringValue; 37 newPerson.age = ageField.intValue; 38 39 NSData *personData = [NSKeyedArchiver archivedDataWithRootObject:newPerson]; 40 41 [saveSystem saveData:personData withKey:@"person"]; 42 43 [saveSystem release]; 44} 45 46@end