The default storage for APDataCenter is the /Documents/Preferences folder in the application sandbox. If your service is independent or handles a large volume of data, you can create a custom storage space.
You can use APCustomStorage to create a custom storage folder. In this folder, you can use all services provided by the unified storage, similar to APDataCenter. For example:
APCustomStorage* storage = [APCustomStorage storageInDocumentsWithName:@"Contact"];Executing this code creates the Documents/Contact folder. This folder also contains commonPreferences for public data and userPreferences for user-specific data. Similar to APDataCenter, APCustomStorage handles user switching automatically. Your service does not need to manage this process.
API description
(instancetype)storageInDocumentsWithName:(NSString*)name;
Creates a custom storage at the path
/Documents/name.
(id)initWithPath:(NSString*)path;
Creates a custom storage at any specified path. You do not typically need this method. Use
storageInDocumentsWithNameinstead. Your service must retain theAPCustomStorageobject created with this method. An error occurs if multipleAPCustomStorageobjects have the samepath.
(APBusinessPreferences*)commonPreferences;
A global storage object for data that is not user-specific. It uses a key-value format to store and retrieve data. Unlike
APDataCenter, you do not need thebusinessparameter when you store key-value data in a custom storage space. You only need thekey.
(APBusinessPreferences*)userPreferences;
The storage object for the currently logged-in user. It uses a key-value format to store and retrieve data. If no user is logged in, this method returns
nil. UnlikeAPDataCenter, you do not need thebusinessparameter when you store key-value data in a custom storage space. You only need thekey.
(id)daoWithPath:(NSString*)filePath userDependent:(BOOL)userDependent;
For more information, see the method of the same name in
APDataCenter.