我最近遵循CodeSchool course to learn iOS,他們推薦使用AFNetworking與服務器交互。通過AFNetworking添加參數請求
我想從我的服務器得到一個JSON,但我需要傳遞一些參數到網址。我不希望將這些參數添加到URL中,因爲它們包含用戶密碼。
對於一個簡單的URL請求,我有以下代碼:
NSURL *url = [[NSURL alloc] initWithString:@"http://myserver.com/usersignin"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@",JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"NSError: %@",error.localizedDescription);
}];
[operation start];
我已經檢查的NSURLRequest的文檔,但並沒有從那裏得到任何有用的東西。
我應該如何傳遞用戶名和密碼到這個請求在服務器中讀取?
是的,在HTTPClient ** requestWithMethod的場景後面:path:parameters:** – onmyway133