2
末我有一個問題與AFNetworking v.1.x因爲這可能是同樣的問題,與2.x的AFNetworking削減在URL中自動添加
#define LOGIN_URL @"http://myserverr.com/login"
NSURL *url = [NSURL URLWithString:LOGIN_URL relativeToURL:[NSURL URLWithString:LOGIN_URL]];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url ];
[httpClient postPath:nil
parameters:@{EMAIL_KEY : email,
PASSWORD_KEY : password}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
id json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
NSDictionary *result = (NSDictionary *)json;
[DCDDownloadHelper loginResult:result];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"[HTTPClient Error]: %@", error.localizedDescription);
dispatch_async(dispatch_get_main_queue(), ^{
}];
但作爲一個結果,我的要求是怎麼回事到URL http://myserverr.com/login/而不是http://myserverr.com/login最後一個斜線添加自動文檔我旁邊
// Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
url = [url URLByAppendingPathComponent:@""];
}
發現但它並不能幫助我:)
你就不能使用'NSURLConnection'呢? – theShay
和..也許這可以幫助你:http://github.com/AFNetworking/AFNetworking/issues/994 – theShay