Skip to content

TheSpydog/TinyKVS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyKVS

A tiny, dependency-free C# wrapper for iCloud Key Value Storage. Only confirmed to work on iOS, but it should work on macOS and tvOS too.

Usage:

At the start of your app:

TinyKVS.Initialize();
TinyKVS.Synchronize();

At the start of every update tick of your app:

TinyKVS.Update();

To detect external changes to KVS data:

// In your code somewhere...
void KVSExternalChangeCallback(TinyKVS.ChangeReason changeReason, string[] keysChanged)
{
	// Do something about the change
}

// When your app starts...
TinyKVS.OnExternalChange += KVSExternalChangeCallback;

To fetch information from KVS:

bool myBool     = TinyKVS.GetBool("example_key_1");
byte[] myData   = TinyKVS.GetData("example_key_2");
double myDouble = TinyKVS.GetDouble("example_key_3");
long mylong     = TinyKVS.GetLong("example_key_4");
string myString = TinyKVS.GetString("example_key_5");

To set information in KVS:

TinyKVS.SetBool("bool_key", myBool);
TinyKVS.SetData("data_key", myData);
// and so on...

To print all key-value pairs stored in KVS:

foreach (var pair in TinyKVS.GetKeyValuePairs())
{
	Console.WriteLine(pair.Key + ": " + pair.Value);
}

To get the estimated size of the key-value store:

ulong kvsSize = GetEstimatedKVSSizeInBytes();

(This will not be exact because it also takes into consideration the size of some NSObjects used for containing the data.)

To remove information from KVS:

TinyKVS.RemoveKeyValuePair("key_to_remove");

// If you want to clear all the data...
TinyKVS.RemoveAllKeyValuePairs();

About

Tiny, dependency-free C# wrapper for iCloud KVS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages