Simple data persistence for iOS and MacOSX
Objective-C C
Permalink
Failed to load latest commit information.
Cocoadis.xcodeproj
English.lproj
RELEASES
COHelper_OSX.h
COHelper_OSX.m
COHelper_iOS.h
COHelper_iOS.m
COObject.h
COObject.m
CORedis.h
CORedis.m
Cocoadis.h
Cocoadis.m
Cocoadis_01_Basic_TestCase.m
Cocoadis_02_Test_Persist.m
Cocoadis_03_Test_GC.m
Cocoadis_04_Test_RedisArray.m
Cocoadis_Prefix.pch
Cocoadis_mate.tmproj
Info.plist
NSObject+Cocoadis.h
NSObject+Cocoadis.m
README.textile
Test_Cocoadis_OSX-Info.plist
Test_Cocoadis_Simulator-Info.plist
cocoadis_graph.graffle
cocoadis_graph.png

README.textile

Simple Data Persistence for iOS and MacOSX

Cocoadis:

  • persist your data easily.
  • works transparently with Strings, Arrays, Dictionaries and Sets.
  • efficient in memory cache.

init:

Global persistence
[[Cocoadis persistence] setBasePath:NSTemporaryDirectory()];
COArray * persistedArray = [[COArray alloc] initAsKey:@"myArray"];
Specific persistence
Cocoadis * persistence1 = [[Cocoadis alloc] initWithPath:[NSString pathWithComponents:
                                            [NSArray arrayWithObjects:
                                            NSTemporaryDirectory(), @"pers1", nil]]];
COArray * persistedArray = [[COArray alloc] initAsKey:@"myArray" persistence:persistence1];
As Foundation Class (only with global persistence)
NSMutableArray * persistedArray = [[NSMutableArray alloc] initAsKey:@"myArray"];
// or from existing object
NSMutableArray * array = [[NSMutableArray alloc] initWithObjects:@"a", @"b", @"c", nil];
[array persistence:@"newArray"];

saving:

per instance
[persistedArray persist];
whole bunch
[[Cocoadis persistence] saveAll];

managing:

releasing unused memory from the cache
[[Cocoadis persistence] cleanCache];
automatic releasing
[[Cocoadis persistence] startAutoClean];
[[Cocoadis persistence] stopAutoClean];
reset empty the cache:
[[Cocoadis persistence] flushCache];
wipe the whole persistence DANGER!!!
[[Cocoadis persistence] clearPersistence]

MacRuby:

>> framework "Cocoadis"
=> true
>> cdis = Array.arrayAsKey :myMacIRB
=> []
ruby style
>> cdis << "Hey"
=> ["Hey"]
>> cdis << "MacRuby"
=> ["Hey", "MacRuby"]
introspect it
>> Cocoadis.persistence.dbCache.inspect
=> "{\"myMacIRB\"=>[\"Hey\", \"MacRuby\"]}"     # Cache contains our message
save it
>> cdis.persist
=> ["Hey", "MacRuby"]
clear cache
>> Cocoadis.persistence.flushCache
=> #<Cocoadis:0x20000d5e0>
>> Cocoadis.persistence.dbCache.inspect
=> "{}"     # Cache is Empty
get it back from persistence
>> recdis = Array.arrayAsKey :myMacIRB
=> ["Hey", "MacRuby"]   # Cocoadis persistence kept it!
play with clones
>> cdis = Array.arrayAsKey :myMacIRB
=> ["Hey", "MacRuby"]   # got the persisted object
>> recdis << "Rocks!"
=> ["Hey", "MacRuby", "Rocks!"]
>> cdis
["Hey", "MacRuby", "Rocks!"]    # also modified

Downloads:

For iOS usage:

To be able to import the static library into an iOS project, you will have to add -ObjC and -all_load to your Other Linker Flags