Loading...
Searching...
No Matches
NCStorageManager Class Reference

Interface for managing multiple key-value storages, providing access and lifecycle control. More...

#include <com/navigine/idl/objc/NCStorageManager.h>

Inherits NSObject.

Instance Methods

(nonnull NSArray< NSString * > *) - getStorageList
 
(nullable NCKeyValueStorage *) - getStorage:
 
(void) - removeStorage:
 

Detailed Description

Interface for managing multiple key-value storages, providing access and lifecycle control.

Referenced from NavigineSdk.

Definition at line 18 of file NCStorageManager.h.

Method Documentation

◆ getStorage:

- (nullable NCKeyValueStorage *) getStorage: (nonnull NSString *) name

Returns a handle to a storage by name, creating it if it does not exist.

Parameters
nameStorage name (case-sensitive).
Returns
Key–value storage instance KeyValueStorage

Swift code snippet:

// Get or create different storage instances
userStorage = storageManager.getStorage(name: "user_preferences")
appStorage = storageManager.getStorage(name: "app_settings")
cacheStorage = storageManager.getStorage(name: "cache")

Objective C code snippet:

// Get or create different storage instances
self.userStorage = [self.storageManager getStorage:@"user_preferences"];
self.appStorage = [self.storageManager getStorage:@"app_settings"];
self.cacheStorage = [self.storageManager getStorage:@"cache"];

◆ getStorageList

- (nonnull NSArray< NSString * > *) getStorageList

Returns the list of all existing user storages.

Returns
List of storage names (implementation currently returns them in alphabetical order).

Swift code snippet:

// Get list of all existing storages
let storageList: [String] = storageManager.getStorageList()
print("Existing storages: \‍(storageList)")

Objective C code snippet:

// Get list of all existing storages
NSArray<NSString *> *storageList = [self.storageManager getStorageList];
NSLog(@"Existing storages: %@", storageList);

◆ removeStorage:

- (void) removeStorage: (nonnull NSString *) name

Removes the storage and all its persisted data. If the storage does not exist, this is a no-op.

Parameters
nameStorage name (case-sensitive).
Note
Existing handles to this storage become invalid after removal and further operations may fail.

Swift code snippet:

// Remove storage and all its data
storageManager.removeStorage(name: "test_storage")
print("Removed test storage")

Objective C code snippet:

// Remove storage and all its data
[self.storageManager removeStorage:@"test_storage"];
NSLog(@"Removed test storage");

The documentation for this class was generated from the following file: