View gist:59e9da3d04aa2ea60590f9c156dab3fb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "success": true,"info": {"code": 200,"message": "OK","records": 10, "current_page":1, "page_size":1000},"data" :[ { | |
"currency_id": 5,"name":"CHF","title":"Switzerland Franc","sign":"CHF","is_wallet": 1},{ "currency_id": | |
46,"name":"CNY","title":"Chinese Yuan","sign":"¥","is_wallet": 1},{ "currency_id": | |
2,"name":"EUR","title":"Euro","sign":"€","is_wallet": 1},{ "currency_id": 43,"name":"IDR","title":"Indonesian | |
Rupiah","sign":"Rp","is_wallet": 1},{ "currency_id": 6,"name":"JPY","title":"Japan Yen","sign":"¥","is_wallet": 1},{ | |
"currency_id": 41,"name":"KES","title":"Kenyan Shilling","sign":"Ksh","is_wallet": 1},{ "currency_id": | |
42,"name":"RUB","title":"Russian Ruble","sign":"₽","is_wallet": 1},{ "currency_id": 45,"name":"TZS","title":"Tanzanian | |
Shilling","sign":"TSh","is_wallet": 1},{ "currency_id": 1,"name":"USD","title":"United States | |
Dollar","sign":"$","is_wallet": 1},{ "currency_id": 44,"name":"VND","title":"Vietnamese Dong","sign":"₫","is_wallet": | |
1}]} |
View MonitorWrites3.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)swizzled_setObject:(id)value forKey:(NSString *)defaultName { | |
[self swizzled_setObject:value forKey:defaultName]; | |
NSLog(@"Set Object %@ for key %@",value,defaultName); | |
} |
View MonitorWrites2.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL isMethodExists = !class_addMethod([self class], defaultSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); | |
if (isMethodExists) { | |
method_exchangeImplementations(defaultMethod, swizzledMethod); | |
} | |
else { | |
class_replaceMethod([self class], swizzledSelector, method_getImplementation(defaultMethod), method_getTypeEncoding(defaultMethod)); | |
} |
View MonitoringWrites2.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SEL defaultSelector = @selector(setObject:forKey:); | |
SEL swizzledSelector = @selector(swizzled_setObject:forKey:); | |
Method defaultMethod = class_getInstanceMethod([self class], defaultSelector); | |
Method swizzledMethod = class_getInstanceMethod([self class], swizzledSelector); | |
BOOL isMethodExists = !class_addMethod([self class], defaultSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); |
View MonitoringWrites1.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSUserDefaults+MonitoringWrites.h" | |
#import <objc/runtime.h> | |
@implementation NSUserDefaults (MonitoringWrites) | |
+ (void)load { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = [self class]; | |
View ViewController1.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import "NSUserDefaults+MyUserDefaults.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController |
View NSUserDefaults+MyUserDefaults.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSUserDefaults+MyUserDefaults.h" | |
@implementation NSUserDefaults (MyUserDefaults) | |
-(void)mySetObject:(id)value forKey:(NSString *)defaultName { | |
[self setObject:value forKey:defaultName]; | |
NSLog(@"Set object %@ for key %@",value,defaultName); | |
} | |
@end |
View XcodeExtension1.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation *)invocation completionHandler:(void (^)(NSError * _Nullable nilOrError))completionHandler { | |
//Checks if the file contains source code of Objective-C or Swift. Then is sets the appropriate variables | |
if ([invocation.buffer.contentUTI isEqualToString:@"public.objective-c-source"]) { | |
logString = @"NSLog("; | |
logCommentString=@"DSLog("; | |
regularExpressionString =@"NSLog\\([^\\)]*\\)[\\s]*\\;"; | |
regularExpressionCommentString=@"\\/\\*DSLog\\([^\\)]*\\)[\\s]*\\;\\*\\/"; | |
} | |
else if ([invocation.buffer.contentUTI isEqualToString:@"public.swift-source"]){ |
View GCDRetainCycle6.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view. | |
self.proArray = [[NSMutableArray alloc]init]; | |
GCDVC2* __weak weakSelf = self; | |
self.postGCDBlock = ^{ | |
GCDVC2* __strong strongSelf = weakSelf; |
View GCDRetainCycle5.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view. | |
self.proArray = [[NSMutableArray alloc]init]; | |
GCDVC2* __weak weakSelf = self; | |
self.postGCDBlock = ^{ | |
[weakSelf.proArray removeObject:@"3"]; |
NewerOlder