This file contains hidden or 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
| // Swift 4 | |
| extension String { | |
| func toAttributedString(color: UIColor?, font: UIFont?) -> NSAttributedString { | |
| do { | |
| var string = self | |
| if color != nil, font != nil { | |
| string = """ |
This file contains hidden or 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
| // file: "UIWebView+Height.h" | |
| #import <UIKit/UIKit.h> | |
| typedef void(^WebViewContentLoaded)(NSString *html, CGSize scrollSize); | |
| @interface UIWebView (Height) <UIWebViewDelegate> | |
| @property (nonatomic, copy) WebViewContentLoaded webLoadedBlock; |
This file contains hidden or 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
| #include <sys/sysctl.h> | |
| + (NSString*)hardwareString | |
| { | |
| int name[] = {CTL_HW,HW_MACHINE}; | |
| size_t size = 100; | |
| sysctl(name, 2, NULL, &size, NULL, 0); // getting size of answer | |
| char *hw_machine = malloc(size); | |
| sysctl(name, 2, hw_machine, &size, NULL, 0); |
This file contains hidden or 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 <objc/runtime.h> | |
| @implementation BaseViewController() | |
| - (void)dealloc | |
| { | |
| [CATransaction setCompletionBlock:nil]; | |
| [NSObject cancelPreviousPerformRequestsWithTarget:self]; | |
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
This file contains hidden or 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
| // [url] : service url | |
| // [parameters] : optional parameters | |
| // [keyPath] : optional root key to retrieve data | |
| // [class] : object class that should return in the array | |
| // | |
| // eg. [PRHTTPSessionManager loadWithURL:@"http://mioservizio.com" parameters:nil keyPath:nil class:[ProductModel class] completion:.... | |
| // eg. [PRHTTPSessionManager loadWithURL:@"http://mioservizio.com" parameters:nil keyPath:@"products.list" class:[ProductModel class] completion:.... | |
| // | |
| + (void)loadWithURL:(NSString*)url |
This file contains hidden or 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
| // UILabel correct way to padding left/right | |
| #import <UIKit/UIKit.h> | |
| @interface CustomLabel : UILabel | |
| @property (nonatomic, assign) UIEdgeInsets edgeInsets; | |
| @end | |
| #import "CustomLabel.h" |
This file contains hidden or 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
| // performance examination procedure | |
| #ifdef DEBUG | |
| double then, now; | |
| now = CFAbsoluteTimeGetCurrent(); | |
| #endif | |
| // | |
| // TODO: your code here | |
| // |
This file contains hidden or 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 <zlib.h> | |
| - (NSUInteger)crc32 | |
| { | |
| // the object requires NSObject-Coding https://github.com/priore/NSObject-Coding | |
| NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self]; | |
| return crc32(0, data.bytes, data.length); | |
| } |
This file contains hidden or 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
| #ifndef dispatch_cancellable_block_h | |
| #define dispatch_cancellable_block_h | |
| #import <Foundation/Foundation.h> | |
| // https://github.com/SebastienThiebaud/dispatch_cancelable_block/issues/2 | |
| typedef void(^dispatch_cancelable_block_t)(BOOL cancel); | |
| NS_INLINE dispatch_cancelable_block_t dispatch_after_delay(NSTimeInterval delay, dispatch_block_t block) { | |
| if (block == nil) { |
This file contains hidden or 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
| @interface ViewController () <UIScrollViewDelegate> | |
| { | |
| CGFloat initialContentOffset; | |
| CGFloat previousContentDelta; | |
| } | |
| @property (nonatomic, assign) CGFloat senseValue; | |
| @end |