SDMPersistence class

Deprecated. Use Cache(with implicit persistence) insteadDefault Persistence implementation Usage // 1. Store some data // retrieve the singleton instance SDMPersistence* persistence = [SDMPersistence instance]; // persist some NSData, and store the uid returned by the method NSString* uid = [persistence storeData:data]; // if no valid uid is returned, there was a problem while trying to store the data if( !uid ) { NSLog("%", "Data could not be persisted!"); // error handling goes here ... } else { // store the uid ... }

Syntax

@interface SDMPersistence : NSObject <SDMPersisting>

Base protocols

Members

All members of SDMPersistence, including inherited members.

Methods
Method Description
- (void) clear Wipes out all persisted content.
+ (id) instance Static Persistence instance.
- (id< SDMCaching >) loadCache: (NSString *) uid_in Loads a previously persisted data based on it's unique identifier.
- (NSData *) loadData: (NSString *) uid_in Loads a previously persisted data based on it's unique identifier.
- (id< NSCoding >) loadSerializable: (NSString *) uid_in Loads a previously persisted object which adopts the NSCoding protocol based on it's unique identifier The UID is returned upon succesfully persisting the data; it has to be managed by the caller in order to retrieve the persisted data or to overwrite it later on.
- (void) removeCacheWithId: (NSString *) uid_in Wipes out a persisted cache content.
- (StoragePolicy) storagePolicy Returns the default storage policy For builds targeting iOS4.0+ the default should be FullProtectionStoragePolicy.
- (NSString *) storeCache: (id< SDMCaching >) cache_in Stores the data to the app's sandbox, returning a unique identifier.
- (NSString *) storeData: (NSData *) data_in withId: (NSString *) uid_in Stores the data to the app's sandbox, returning a unique identifier.
- (NSString *) storeSerializable: (id< NSCoding >) serializable_in withId: (NSString *) uid_in Stores serializable data to the app's sandbox, returning a unique identifier The returned UID has to be managed by the caller in order to retrieve the persisted data or to overwrite the contents using a successive storeCache: call.

Usage

// retrieve the previously persisted NSData, based on the uid we received when calling the storeData: API 
NSData* data = [persistence loadData:uid];