Skip to content

Instantly share code, notes, and snippets.

@kam800
Created January 20, 2016 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kam800/70ff776a3bb5818a0f56 to your computer and use it in GitHub Desktop.
Save kam800/70ff776a3bb5818a0f56 to your computer and use it in GitHub Desktop.
Override TwitterKit keychain kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock
@import Foundation;
#import <objc/runtime.h>
@interface TWTRGenericKeychainItem: NSObject
- (NSMutableDictionary *)fullRawRepresentation;
@end
@interface TWTRGenericKeychainItem (KeychainFix)
@end
@implementation TWTRGenericKeychainItem (KeychainFix)
+ (void)load {
Class class = [self class];
SEL originalSelector = @selector(fullRawRepresentation);
SEL swizzledSelector = @selector(changed_fullRawRepresentation);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
}
- (NSMutableDictionary *)changed_fullRawRepresentation {
NSMutableDictionary *d = [self changed_fullRawRepresentation];
d[(__bridge id)kSecAttrAccessible] = (__bridge id)(kSecAttrAccessibleAfterFirstUnlock);
return d;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment