POSTメソッドでリクエストしたいのですが、その後jsonデータやを返してほしいのですNSDictionary
が、成功した場合にしか文字列を返すことができません
お気に入り NSString *response = [operation responseString];
NSdictionary
代わりにそれらを返す方法を知っている人はいNSString
ますか?
-(IBAction)SubmitLogin:(id)sender{
NSLog(@"Login");
// NSLog(@"%@",username);
//START FUNGSI UNTUK POST, PUT, DELETE
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:signinUrl];
[httpClient defaultValueForHeader:@"Accept"];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"someuser", @"username",
@"somepassword",@"password",
nil];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST"
path:@""
parameters:params];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];
[operation setCompletionBlockWithSuccess:
^(AFHTTPRequestOperation *operation,
id responseObject) {
NSString *response = [operation responseString];
NSLog(@"response: %@",response);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", [operation error]);
}];
//call start on your request operation
[operation start];