2014-09-06 154 views
1

我有一個問題關於AFNetworking 2.0AFNetworking 2.0和GET請求參數

我不得不做出這樣的GET請求:

http://myhost.come/entity?language=en&query=$UserId=14 and $EntityCreationDate>'2014-09-01' 

如何生成此請求的字典參數?

我特別不明白我怎麼能建立這個:and $EntityCreationDate>'2014-09-01'

回答

0

在這裏,我找到了一個good tutorial

其中指出一個簡單的GET請求可以發送這樣的:

AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://samwize.com/"]]; 
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" 
                 path:@"http://samwize.com/api/pigs/" 
                parameters:nil]; 
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]]; 
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 
    // Print the response body in text 
    NSLog(@"Response: %@", [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]); 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    NSLog(@"Error: %@", error); 
}]; 
[operation start];