2013-01-17 1 views
0

현재 ASIHttpRequest에서 MKNetworkKit으로 전환하려고하고 있으며 게시 데이터에 문제가 있습니다. MKNetworkKit에서 다음을 어떻게 수행합니까?MKNetworkKit 게시 데이터를 추가하는 방법

ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL : url];

[appStringPostData : [[NSString stringWithFormat : @ "{\"버전 \ ": % @, \"값 \ ": \"% \\ " ","버전 ","버전 ", 버전, [[UIDevice currentDevice] uniqueIdentifier], [[UIDevice currentDevice] systemVersion]] 데이터 사용 인코딩 : NSUTF8StringEncoding]];

MKNetworkKit에 게시 데이터를 추가하는 방법을 모르겠습니다. addData 메소드를 찾았지만 위와 같은 데이터를 값 {} 안에 추가 데이터로 추가 할 수 없습니다.

어떻게 알 수 있습니까?

답변

-1

비록 내가이 일에 매우 익숙해도 내가하고있는 일을 너와 함께 나누도록하겠다.

먼저 엔진을 만듭니다 (여기서 내가 호출하는 서비스가 있습니다). 내가 서비스 전화 할게 기능에서 다음

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 

    { 
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
     if (self) { 
      engine_= [[MKNetworkEngine alloc] initWithHostName:@"www.xxx.gr"]; 
      // Custom initialization 
     } 
     return self; 
    } 

: 내 초기화에서

@interface INGMainViewController(){ 
    MKNetworkEngine *engine_; 

} 

:

내 인터페이스에서

NSDictionary *formParams = [NSDictionary dictionaryWithObjectsAndKeys: 
          theClientCode, @"ClientCode", 
          theContractNumber, @"ContractCode", 
          theAppleID, @"AppleID", 
          @" ", @"AndroidID", 
          @" ", @"WindowsID", 
          uid, @"AppleDeviceID", 
          @" ", @"AndroidDeviceID", 
          @" ", @"WindowsDeviceID", 
          theCellPhone, @"TelephoneNumber" 
          , nil]; 

    MKNetworkOperation *operation = [self.engine operationWithPath:@"/services/Authentication.ashx" 
                  params: formParams 
                 httpMethod:@"POST"]; 


    [operation addCompletionHandler: 
    ^(MKNetworkOperation *operation) 
    { 
     NSLog(@" Operation succeds: %@", [operation responseString]); 
    } 
         errorHandler:^(MKNetworkOperation *errorOperation, NSError *error) 
         { 
          NSLog(@" Errors occured: %@", error); 
         }]; 
    [self.engine enqueueOperation:operation]; 
} 

을 ... 그리고 그 모두입니다.

물론 나는 여전히 몇 가지 문제점에 직면 해 있습니다. 그러나 나는 키트에서 오지 않는다고 생각합니다.

나는 당신을 도왔기를 바랍니다.

0

이 시도 :

MKNetworkOperation *op = [self operationWithPath:INIT_URL params:body httpMethod:@"POST" ssl:YES]; 
[op setPostDataEncoding:MKNKPostDataEncodingTypeJSON];//This is important 
[op addCompletionHandler:^(MKNetworkOperation *completedOperation) 
관련 문제