wikipedia 定义:
Functional Programming is a programming paradigm
- treats computation as the evaluation of mathematical functions.
- avoids changing-state and mutable data
函数式编程是一种编程范式,它将计算机运算视为数学上的函数计算,并且避免使用程序状态以及易变对象
void DumpObjcMethods(Class clz) { | |
unsigned int methodCount = 0; | |
unsigned int propertyCount = 0; | |
Method *methods = class_copyMethodList(clz, &methodCount); | |
objc_property_t *properties = class_copyPropertyList(clz, &propertyCount); | |
printf("Found %d methods on '%s'\n", methodCount, class_getName(clz)); | |
+ (BOOL)isFund:(NSString *)symbol | |
{ | |
for (NSString *fundSymbol in [self funds]) { | |
if ([symbol hasPrefix:fundSymbol]) { | |
return YES; | |
} | |
} | |
return NO; | |
} |
NSString *path = [[NSBundle mainBundle] pathForResource:@"ad" ofType:@"json"]; | |
NSData *jsonData = [NSData dataWithContentsOfFile:path]; | |
jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil]; |
--- | |
Language: Cpp | |
# BasedOnStyle: LLVM | |
AccessModifierOffset: 0 | |
AlignAfterOpenBracket: true | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: true | |
AlignTrailingComments: true | |
AllowAllParametersOfDeclarationOnNextLine: true | |
AllowShortBlocksOnASingleLine: false |
#import "RoundImageView.h" | |
@implementation RoundImageView | |
- (instancetype)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
self.clipsToBounds = YES; | |
self.contentMode = UIViewContentModeScaleAspectFill; |
- (NSArray *)constrainSubview:(UIView *)subview toMatchWithSuperview:(UIView *)superview | |
{ | |
subview.translatesAutoresizingMaskIntoConstraints = NO; | |
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(subview); | |
NSArray *constraints = [NSLayoutConstraint | |
constraintsWithVisualFormat:@"H:|[subview]|" | |
options:0 | |
metrics:nil | |
views:viewsDictionary]; |
#import "UIImageView+Util.h" | |
@implementation UIImageView (Util) | |
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder animation:(BOOL)animation | |
{ | |
__weak typeof (self) weakSelf = self; | |
[self setImageWithURL:url | |
placeholderImage:placeholder | |
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { |
typedef NS_ENUM(NSInteger, JYImageType) { | |
JYImageTypeJPEG, | |
JYImageTypePNG, | |
JYImageTypeUnknown, | |
}; | |
static inline JYImageType JYImageTypeFromData(NSData *imageData) { | |
if (imageData.length > 4) { | |
const unsigned char * bytes = [imageData bytes]; | |
NSString * JYKeyPathForSelectors(SEL selector, ...); | |
inline NSString * JYKeyPathForSelectors(SEL selector, ...) { | |
if (!selector) { | |
return nil; | |
} | |
NSMutableArray *selectors = [NSMutableArray array]; | |
va_list args; | |
va_start(args, selector); |