+ (AnyPromise *) retry:(int)count delay:(NSTimeInterval)delay block:(AnyPromise *(^)(void))block {
AnyPromise* (^attemp)(void) = ^AnyPromise*() {
return block().catch(^(NSError *error) {
if(count <= 1) {
@throw error;
}
return PMKAfter(delay).then(^{
return [AnyPromise retry:count-1 delay:delay block:block];
});
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
typedef void (^fg_PFArrayResultBlock)(NSArray *PF_NULLABLE_S objects, NSError *PF_NULLABLE_S error, BOOL isCache, BOOL done); | |
@interface PFQuery (IsCache) | |
- (void)fg_findObjectsInBackgroundWithBlock:(PF_NULLABLE fg_PFArrayResultBlock)block | |
willLoadFromCache:(void (^ __nullable)())willLoadFromCache | |
willLoadFromNetwork:(void (^ __nullable)())willLoadFromNetwork; | |
@end | |
@implementation PFQuery (IsCache) |
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
extension UITextField { | |
func setTextLeftPadding(left:CGFloat) { | |
var leftView:UIView = UIView(frame: CGRectMake(0, 0, left, 1)) | |
leftView.backgroundColor = UIColor.clearColor() | |
self.leftView = leftView; | |
self.leftViewMode = UITextFieldViewMode.Always; | |
} | |
} |