BlockExtension 0.0.3

BlockExtentions 0.0.3

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released 最后发布时间2014年12月

未指定维护。



  • Max Lunin

基于_BLOCK的扩展。

添加到NSArray的方法

-(instancetype)map:( id(^)(id object) )mapBlock;

-(instancetype)select:( BOOL(^)(id object) )predicate;

-(instancetype)reject:( BOOL(^)(id object) )predicate;

-(instancetype)rejectObject:(id)rejectedObject;

-(id)findFirst:( BOOL(^)(id object) )predicate;

-(BOOL)all:( BOOL(^)(id object) )predicate;

-( BOOL)any:( BOOL(^)(id object) )predicate;

-(id)reduce:( id(*)(id aggregation, id object) )reduceBlock initialValue:( id )initialValue;

-(NSSet*)set;

+(instancetype)arraySize:( NSUInteger )size generator:( id(*)(NSUInteger index) )generatorBlock;

-(instancetype)classOf:( Class )classOf; // used: -isKindOfClass

-(instancetype)sort; // used -compare

-(instancetype)distinct;

-(instancetype)notNull; // reject NSNull instances

-(NSNumber estrellas)(sum:( NSNumber *(^)(id object) )toNumber);

-(NSNumber estrellas)(avg:( NSNumber *(^)(id object) )toNumber);

添加到NSSet的方法

-(instancetype)setMinusSet:( NSSet* )set;

-(instancetype)setUnionSet:( NSSet* )set;

-(instancetype)setIntersectSet:( NSSet* )set;

添加到UIAlertView的方法

+(instancetype)alertViewWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;

-(instancetype)alertViewStyle:( UIAlertViewStyle )style;

-(instancetype)alertViewClickedButtonAtIndex:( void(*)(UIAlertView* alert, NS UInteger idx) )callback;

-(instancetype)alertViewCancel:( void(*)(UIAlertView* alert) )callback;

-(instancetype)willPresentAlertView:( void(*)(UIAlertView* alert) )callback;

-(instancetype)didPresentAlertView:( void(*)(UIAlertView* alert) )callback;