天天看點

安卓設定keychain_SAMkeychain的簡單使用

SAMkeychain可以用來儲存使用者的隐私資訊。

安卓設定keychain_SAMkeychain的簡單使用

結構展示

一:儲存資料

+ (BOOL)setPasswordData:(NSData *)password forService:(NSString *)serviceName account:(NSString *)account;

+ (BOOL)setPasswordData:(NSData *)password forService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error __attribute__((swift_error(none)));

+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account;

+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error __attribute__((swift_error(none)));

二:擷取資料

+ (NSData *)passwordDataForService:(NSString *)serviceName account:(NSString *)account;

+ (NSData *)passwordDataForService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error __attribute__((swift_error(none)));

+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account;

+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)accou;

三:删除資料

+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account;

+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error __attribute__((swift_error(none)));

四:擷取所有帳号資訊

+ (NSArray *> *)allAccounts;

//NSArray *allAccounts = [SAMKeychain allAccounts];

+ (NSArray *> *)allAccounts:(NSError *__autoreleasing *)error __attribute__((swift_error(none)));

+ (NSArray *> *)accountsForService:(NSString *)serviceName;

+ (NSArray *> *)accountsForService:(NSString *)serviceName error:(NSError *__autoreleasing *)error __attribute__((swift_error(none)));

//通過下面方法可以配置篩選的資訊,

- (NSArray *> *)fetchAll:(NSError **)error;

安卓設定keychain_SAMkeychain的簡單使用

瞪誰誰懷孕