用户登录后,您将获得一个令牌(摘要或oauth),您可以将其设置到HTTP Authorization标头中,并授予您访问Web服务的权限.如果您将用户的姓名,密码和此令牌存储在手机的某个位置(用户默认值,或最好是在钥匙串中),则每次应用程序重新启动时,您的用户都会自动登录.
但是如果你的令牌到期怎么办?然后你"只需" 要求一个新的令牌,如果用户没有更改他的密码,那么他应该再次自动登录.
实现此令牌刷新操作的一种方法是子类化AFHTTPRequestOperation并处理401 Unauthorized HTTP Status代码以便询问新令牌.发出新令牌后,您可以再次调用失败的操作,该操作现在应该成功.
然后,您必须注册此类,以便每个AFNetworking请求(getPath,postPath,...)现在使用此类.
[httpClient registerHTTPOperationClass:[RetryRequestOperation class]]
这是这样一个类的例子:
static NSInteger const kHTTPStatusCodeUnauthorized = 401;
@interface RetryRequestOperation ()
@property (nonatomic, assign) BOOL isRetrying;
@end
@implementation RetryRequestOperation
- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *, id))success
                              failure:(void (^)(AFHTTPRequestOperation *, NSError *))failure
{
    __unsafe_unretained RetryRequestOperation *weakSelf = self;
    [super setCompletionBlockWithSuccess:success failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        // In case of a 401 error, an authentification with email/password is tried …我试图仅使用图层功能在两个UIView上实现一种折纸转换.我们的想法是用透视效果折叠两个视图.两个视图都有透视,过渡由每个视图上的旋转定义,以及一个视图上的平移,使得该视图似乎附加到另一个视图.
问题是视图在转换过程中彼此重叠.我不想使用zPosition来直观地避免这种重叠,我真的希望这两个视图就好像它们被共享端绑定在一起一样.这是过渡的代码.
任何想法,或任何其他解决方案?

- (void)animateWithPerspective
{
    CGFloat rotationAngle = 90;
    CATransform3D transform = CATransform3DIdentity;
    UIView *topView;
    UIView *bottomView;
    UIView *mainView;
    CGRect frame;
    CGFloat size = 200;
    mainView = [[UIView alloc] initWithFrame:CGRectMake(10,10, size, size*2)];
    [self.view addSubview:mainView];
    bottomView = [[UIView alloc] initWithFrame:CGRectZero];
    bottomView.layer.anchorPoint = CGPointMake(0.5, 1);
    bottomView.frame = CGRectMake(0, size, size, size);
    bottomView.backgroundColor = [UIColor blueColor];
    [mainView addSubview:bottomView];
    topView = [[UIView alloc] initWithFrame:CGRectZero];
    topView.layer.anchorPoint = CGPointMake(0.5, 0);
    topView.frame = CGRectMake(0, 0, size, size);
    topView.backgroundColor = [UIColor redColor];
    [mainView addSubview:topView];
    transform.m34 = 1.0/700.0; …