Skip to content

Instantly share code, notes, and snippets.

@berzniz
Created May 18, 2013 16:07
Show Gist options
  • Save berzniz/5604924 to your computer and use it in GitHub Desktop.
Save berzniz/5604924 to your computer and use it in GitHub Desktop.
//
// TBKeychainCounter.h
//
// Created by Tal Bereznitskey on 5/11/13.
// Copyright (c) 2013 Tal Bereznitskey. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TBKeychainCounter : NSObject
+ (NSInteger)counterForKey:(NSString *)key;
+ (void)increaseCounterForKey:(NSString *)key;
@end
//
// TBKeychainCounter.m
//
// Created by Tal Bereznitskey on 5/11/13.
// Copyright (c) 2013 Tal Bereznitskey. All rights reserved.
//
#import "TBKeychainCounter.h"
#import "PDKeychainBindings.h"
@implementation TBKeychainCounter
+ (NSInteger)counterForKey:(NSString *)key
{
return [[[PDKeychainBindings sharedKeychainBindings] objectForKey:key] integerValue];
}
+ (void)increaseCounterForKey:(NSString *)key
{
NSInteger counter = [self counterForKey:key] + 1;
NSString *counterString = [NSString stringWithFormat:@"%d", counter];
[[PDKeychainBindings sharedKeychainBindings] setObject:counterString forKey:key];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment