ABSaveSystem is a helper class written in Objective-C which can be used in iOS and Mac OSX Applications to save data. (Also works perfectly with the iOS/Mac game engine "cocos2D"
-
Helper Methods for quickly saving strings (NSString), integers (int), floats (float) and booleans (BOOL)
-
Save NSData
-
Saved Data is encrypted (With Public Apple frameworks->iTunes Connect safe)
-
Save/Load to/from multiple files
-
Saves the data into a clean .absave binary file
-
Mac / iOS / Cocos2D compatible
-
Extremely easy to use
-
Add File from "ABSaveSystem" folder to your project and import ABSaveSystem.h into your class, in the ASaveSystem.m file at the top change "AppName" to whatever your App is named and "OS" to either IOS or MAC.
-
Init ABSaveSystem
ABSaveSystem *saveSystem = [ABSaveSystem saveSystem];
-
- You can basically convert any object that conforms to the NSCoding protocol to an NSData Object and safe that with the SaveSystem (See the Example App for using a Custom NSObject subclass exmaple)
NSArray *myArray = [NSArray arrayWithObjects:@"Object1", @"Object2", nil];
NSData *arrayData = [NSKeyedArchiver archivedDataWithRootObject:myArray];
[saveSystem saveData:arrayData withKey:@"myarray"];
2. Load NSData objects:
NSData *loadedData = [saveSystem loadDataForKey:@"myarray"];
NSArray *loadedArray = [NSKeyedUnarchiver unarchiveObjectWithData:loadedData];
- You can basically convert any object that conforms to the NSCoding protocol to an NSData Object and safe that with the SaveSystem (See the Example App for using a Custom NSObject subclass exmaple)
-
There are also Helper Methods that let you very quickly save strings/ int's / floats's / BOOL's
[mySaveSystem saveString:@"string Value" withKey:@"stringKey"];
[mySaveSystem saveINT:4563 withKey:@"intKey"];
[mySaveSystem saveFloat:5.674f withKey:@"floatKey"];
[mySaveSystem saveBool:YES withKey:@"boolKey"];
- Load strings/ int's / floats's
NSLog(@"loaded String: %@", [mySaveSystem loadStringForKey:@"stringKey"]);
NSLog(@"loaded INT: %i", [mySaveSystem loadINTForKey:@"intKey"]);
NSLog(@"loaded Float: %f", [mySaveSystem loadFloatForKey:@"floatKey"]);
- Load data directly into variables
NSString *myString = [mySaveSystem loadStringForKey:@"stringKey"]
int myINT = [mySaveSystem loadINTForKey:@"intKey"]
float myINT = [mySaveSystem loadFloatForKey:@"floatKey"]
- Dont forget to release the Save System after use!
[mySaveSystem release];
Other Features
- Use following method to save / load to/ from a different file(.plist):
ABSaveSystem *ss = [ABSaveSystem saveSystem];
ss.superFileName = @"MyPlistName";
//Do saving / Loading
- If you need to set the OS (mac/iOS) dynamically in code use the "superOS" property of the ABSaveSystem instance to either "ssIOS" or "ssMAC" (useful for projects with seperate MAC/iOS Targets)
- There is also a convience method to save/load NSData to different .plist's:
[saveSystem saveData:myData withKey:@"myKey" fileName:@"MyPlistName"];
___
If you like this consider supporting me by buying my game "Be The Kiwi" for iPhone/iPad:
Be The Kiwi for iOS
or
Downloading "Be The Kiwi" for Mac OS for free and leaving a kind review ;)
Be The Kiwi for Mac
Feel free to contact me about any improvement requests / issues via mail
([email protected]) or via Twitter (http://www.twitter.com/blunckalex)
ABSaveSystem is licensed under the MIT License…or in simple use as you please, just don't sell the code itself ;)
Copyright (c) 2012 Ablfx (Alexander Blunck)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.