Coder Social home page Coder Social logo

bryant1410 / absavesystem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexblunck/absavesystem

0.0 3.0 0.0 94 KB

ABSaveSystem - Obj-C Helper class for iOS and Mac OS X to save NSData, other Objects and primitive data types to persistant storage.

Home Page: http://ablfx.com

License: MIT License

Objective-C 100.00%

absavesystem's Introduction

ABSaveSystem

ABSaveSystem - Obj-C Helper class for iOS and Mac OS X to save NSData, other Objects and primitive data types to persistant storage.

Basics

ABSaveSystem consists only of static methods, so all you need to do is add the ABSaveSystem .h / .m files and import the header

#import "ABSaveSystem.h"

All data is saved into a binary file named appname.abss, in the Documents directory on iOS or the "Application Support/appname>" directory on OS X.

Save

//NSData
[ABSaveSystem saveData:myData key:@"myData"];

//NSString
[ABSaveSystem saveString:@"Hello World" key:@"myString"];

//Object conformign to NSCoding protocol
[ABSaveSystem saveObject:myObject key:@"myObject"];

//NSInteger
[ABSaveSystem saveInteger:23 key:@"myInteger"];

//CGFloat
[ABSaveSystem saveFloat:10.0f key:@"myFloat"];

//BOOL
[ABSaveSystem saveBool:YES key:@"myBool"];

//Check ABSaveSystem header for all available methods

Load

//NSData
NSData *myData = [ABSaveSystem dataForKey:@"myData"];

//NSInteger
NSInteger myInteger = [ABSaveSystem integerForKey:@"myInteger"];

//The other load methods follow the same naming convention

Encryption

/*
By Default ABSaveSystem saves all data to a binary file unencrypted
You can change this behaviour by either adding following directive before importing the header file:
*/
#define ABSS_ENCRYPTION_ENABLED YES 

//...or using following methods to save/load data:

NSData *mySecretData = [NSKeyedArchiver archivedDataWithRootObject:@234];
[ABSaveSystem saveData:mySecretData key:@"boughtCoins" encryption:YES];
    
NSNumber *boughtCoins = [NSKeyedUnarchiver unarchiveObjectWithData:[ABSaveSystem dataForKey:@"boughtCoins" encryption:YES]];

Misc

//Log all saved values
[ABSaveSystem logSavedValues];

//Delete all saved data
[ABSaveSystem truncate];

//Turn off logging, add following directive before importing header:
#define ABSS_LOGGING NO

//Set a custom key for encryption (Recommended), add following directive before importing header:
#define ABSS_AESKEY @"MySecretKey"
LICENSE

ABSaveSystem is licensed under the MIT License. Check the LICENSE file, of course attribution is always a nice thing.

absavesystem's People

Contributors

bryant1410 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.