mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
Added contains and clear implementations for iOS Settings
This commit is contained in:
parent
ce8bedb340
commit
17e18a2a7a
1 changed files with 46 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
|||
|
||||
using System;
|
||||
using System;
|
||||
#if __UNIFIED__
|
||||
using Foundation;
|
||||
#else
|
||||
|
@ -230,6 +229,50 @@ namespace Bit.iOS.Core.Services
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all keys from settings
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
lock(locker)
|
||||
{
|
||||
var defaults = _defaults;
|
||||
try
|
||||
{
|
||||
defaults.RemovePersistentDomain(NSBundle.MainBundle.BundleIdentifier);
|
||||
defaults.Synchronize();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Unable to clear all defaults. Message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the key has been added.
|
||||
/// </summary>
|
||||
/// <param name="key">Key to check</param>
|
||||
/// <returns>True if contains key, else false</returns>
|
||||
public bool Contains(string key)
|
||||
{
|
||||
lock(locker)
|
||||
{
|
||||
var defaults = _defaults;
|
||||
try
|
||||
{
|
||||
var nsString = new NSString(key);
|
||||
var setting = defaults.ValueForKey(nsString);
|
||||
return setting != null;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("Unable to clear all defaults. Message: " + ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue