0
NSURL *url = [NSURL URLWithString:@"contact.php"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"companyID", constCompanyID,
nil];
NSURLRequest *request = [httpClient requestWithMethod: @"POST" path:@"contact.php" parameters:params];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
for(id entry in JSON)
{
self.strAddr = [entry valueForKeyPath:@"addr"];
CCLOG(@"Address: %@", self.strAddr);
}
} failure:nil];
[operation start];
CCLOG(@"Address: %@", strAddr);
로그에서 주소는 null입니다. PHP는 괜찮습니다. 브라우저에서, 그것은 내가 원하는 것을 반환합니다.AFJsonRequest와 AFHttpClient가 함께 작동합니까?
이 코드는 변수에 전달할 AFHTTPClient를 추가 할 때까지 작동했습니다. 나는 틀린 일을해야하거나 그렇지 않을 수 있습니까?