Tag: 完成块

Alamofire Post请求之后如何获得完成处理程序/块?

我有一个处理Apple Push Notification Service远程通知的方法。 当这个方法被执行时,我希望它调用我的服务器,并使用Alamofire库进行HTTP POST请求。 我想执行另一个方法来处理POST请求的响应。 我的问题是,我正在使用现有的API从这个POST请求中的服务器获取configuration文件。 所以我需要使用这个现有的API,并找出何时从远程通知中明确触发了此configuration文件提取。 由于Alamofire请求是在后台队列中完成的,在从服务器接收到configuration文件后,如何执行方法? 什么是解决这个问题的好select? 谢谢!

用BOOL /完成块停止自动反向/无限重复UIViewanimation

我设置了以下UIView animateWithDuration:方法,目的是在程序的其他地方设置我的animationOn BOOL来取消无限循环的重复。 我的印象是,每当animation的一个循环结束时就会调用completion块,但看起来并不是这样。 completion块是否在重复animation中被调用? 如果不是,还有另一种方法可以阻止这种方法以外的animation? – (void) animateFirst: (UIButton *) button { button.transform = CGAffineTransformMakeScale(1.1, 1.1); [UIView animateWithDuration: 0.4 delay: 0.0 options: UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations: ^{ button.transform = CGAffineTransformIdentity; } completion: ^(BOOL finished){ if (!animationOn) { [UIView setAnimationRepeatCount: 0]; } }]; }