AFNetworking Store凭据

时间:2015-04-07 23:39:48

标签: ios objective-c afnetworking

我是AFNetworking的新手。我正在使用ASIHTTPRequest,我发现它更容易,但听到它没有用。

现在我正在尝试使用AFNetworking重做我使用ASIHTTPRequest所做的一切。我创建了一个登录API的方法:

-(BOOL)User:(NSString *)user andPassWordExists:(NSString *)password
{


   __block BOOL isLoggedIn;
   NSURL *url = [NSURL URLWithString:kIP];
   NSURLRequest *request = [NSURLRequest requestWithURL:url];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
                                         initWithRequest:request];

    [operation setCredential:[NSURLCredential credentialWithUser:[@"losanihomes" stringByAppendingString:user]
                                                        password:password persistence:NSURLCredentialPersistenceNone]];



    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {


        isLoggedIn = YES;


    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        isLoggedIn = NO;

    }];


    [operation start];
    return isLoggedIn;
}

现在我的问题是如何存储这些凭据然后重复使用它们?在ASIHTTPRequest中,它会自动存储凭据。

0 个答案:

没有答案
相关问题