문제는 내가 메고 API를 호출하지만, API가 모든 다른 명령문이 실행되기 전에 객체를 리턴 할 때입니다.호출 후 API가 응답을 기다리지 않습니다.
NSMutableArray *list=[Magento.service startSession];
NSLog(@"Record is:%@",list);
내가 수정 한
startSession 방법은 다음과 같습니다
는- (NSMutableArray *)startSession
{
NSString *_sessionID;
NSNumber *nsPage =[NSNumber numberWithInt:1];
NSNumber *nsData =[NSNumber numberWithInt:10];
NSMutableArray *listOfName = [[NSMutableArray alloc] init];
NSArray *args = [NSArray arrayWithObjects:nsPage,nsData,nil ];
@synchronized(self) {
_sessionID = sessionID;
}
if (_sessionID != FAILED_SESSION)
dispatch_group_enter(session_group);
[client postPath:@"login" parameters:@{@"username": MAGENTO_USERNAME, @"apiKey": MAGENTO_API_KEY} success:^(AFHTTPRequestOperation *operation, id responseObject) {
sessionID = responseObject;
dispatch_group_leave(session_group);
[client postPath:@"call" parameters:@{@"sessionId":sessionID, @"resourcePath":@"callforprice_collection.getCallForPriceCollection",
@"args":args
} success:^(AFHTTPRequestOperation *operationData, id responseData) {
NSLog(@"Response : %@",responseData);
[listOfName addObject:[responseData valueForKey:@"name"]];
} failure:^(AFHTTPRequestOperation *operationData, NSError *error) {
NSLog(@"Response is not get");
sessionID = FAILED_SESSION;
}];
NSLog(@"got session %@", sessionID);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
sessionID = FAILED_SESSION;
}];
return listOfName;
}
O/P는
2013-05-03 06:27:16.272 CallForPrice[3120:c07] Record is:()
2013-05-03 06:27:19.836 CallForPrice[3120:c07] got session 88ef34087a12809334ae3a0c839f85b6
** response that i have printed in method**
2013-05-03 06:27:22.048 CallForPrice[3120:c07] Response : (
{
"callforprice_id" = 13;
country = Austria;
"created_time" = "2013-05-03 12:03:05";
emailid = "[email protected]";
message = hfhftrfygjh;
name = "Richard Conover";
"phone_no" = 8977896;
"product_name" = Ottoman;
"product_options" = "";
"update_time" = "0000-00-00 00:00:00";
},
{
"callforprice_id" = 12;
country = "Antigua and Barbuda";
"created_time" = "2013-05-03 12:01:24";
emailid = "[email protected]";
message = sdfsdfsdfwe;
name = "Richard Conover";
"phone_no" = 5645;
"product_name" = Ottoman;
"product_options" = "";
"update_time" = "0000-00-00 00:00:00";
},
{
"callforprice_id" = 11;
country = Angola;
"created_time" = "2013-05-03 11:58:51";
emailid = "[email protected]";
message = 6tyrtyryrty;
name = "Kaitlyn Matheson";
"phone_no" = 564564;
"product_name" = Ottoman;
"product_options" = "";
"update_time" = "0000-00-00 00:00:00";
},
startSession이 NSLOG 통화하기 전에 인쇄되는 일이 무엇인지 실제로 기록을 표시입니다 응답. 이
renewSession이 다른 스레드에서 실행되기 때문에 –
왜 한 줄이 주석 처리 되었습니까? – Undo